Re: why is perl -e 'unlink(glob("*"))' so much faster than rm ?
- From: Sherm Pendley <sherm@xxxxxxxxxxxxxxxxxxxxxxxxxxxxx>
- Date: Mon, 17 Jul 2006 13:23:09 -0400
ewaguespack@xxxxxxxxx writes:
i had a situation that required that i remove several thousand zero
byte files, and i tried this first:
# find . -type f -exec rm -f {} \;
this was taking ages, so on a hunch I decided to try this to see it I
got any better results:
# perl -e 'unlink(glob("*"))'
surprisingly the perl unlink took about a quarter of a second to remove
1000 files versus 30 seconds with find / rm
any idea why?
The find was spawning a new instance of 'rm' for each file - very inefficient.
The equivalent to your Perl code would be to use find to get a list of files,
and then use 'xargs' to pass that whole list to one instance of 'rm':
find . -type f -print0 | xargs -0 rm -f
sherm--
--
Web Hosting by West Virginians, for West Virginians: http://wv-www.net
Cocoa programming in Perl: http://camelbones.sourceforge.net
.
- Follow-Ups:
- Re: why is perl -e 'unlink(glob("*"))' so much faster than rm ?
- From: ewaguespack
- Re: why is perl -e 'unlink(glob("*"))' so much faster than rm ?
- References:
- why is perl -e 'unlink(glob("*"))' so much faster than rm ?
- From: ewaguespack
- why is perl -e 'unlink(glob("*"))' so much faster than rm ?
- Prev by Date: Re: why is perl -e 'unlink(glob("*"))' so much faster than rm ?
- Next by Date: Re: skip path prune
- Previous by thread: Re: why is perl -e 'unlink(glob("*"))' so much faster than rm ?
- Next by thread: Re: why is perl -e 'unlink(glob("*"))' so much faster than rm ?
- Index(es):
Relevant Pages
|
|