in reply to Re: UNIX command - remove 0 byte file
in thread UNIX command - remove 0 byte file
find /whatever/path/ -size 0 -exec rm {} \;One comment. "-exec" is generally not the best idea unless you care that your command is executed on exactly one file at a time. The problem with exec is that it spawns a new process for every file that it finds. Which isn't bad if the process takes a long time; the tiem spent in starting a new process is shadowed by the run time of the executable. However, in the case of rm, the operation is very quick, so the converse is true.
In this case, we have a couple of options. In looking at my local find man page, I see that find has a -delete option. This may be a Linux-ism though, as I don't seem to remember this on Solaris. Failing that, we always have xargs. And so, your invocation becomes either find . -size 0 -delete or find . -size 0 | xargs rm. I've seen the xargs version speed up an invocation of find by roughly an order of magnitude. YMMV.
thor
Feel the white light, the light within
Be your own disciple, fan the sparks of will
For all of us waiting, your kingdom will come
|
---|
Replies are listed 'Best First'. | |
---|---|
Re^3: UNIX command - remove 0 byte file
by Moron (Curate) on Sep 23, 2005 at 12:33 UTC | |
by Anonymous Monk on Sep 23, 2005 at 12:48 UTC | |
by thor (Priest) on Sep 23, 2005 at 13:28 UTC | |
by Anonymous Monk on Sep 23, 2005 at 13:46 UTC | |
by thor (Priest) on Sep 23, 2005 at 14:40 UTC | |
| |
by Moron (Curate) on Sep 23, 2005 at 13:59 UTC | |
by Anonymous Monk on Sep 23, 2005 at 14:15 UTC | |
by Moron (Curate) on Sep 23, 2005 at 15:05 UTC | |
| |
by Moron (Curate) on Sep 23, 2005 at 13:06 UTC | |
by mhacker (Sexton) on Sep 23, 2005 at 12:55 UTC | |
by YuckFoo (Abbot) on Sep 23, 2005 at 17:28 UTC |