Tugger the SLUGger!SLUG Mailing List Archives

Re: [SLUG] removing duplicate files


On 08/07/07, Peter Chubb <peter@xxxxxxxxxxxxxxxxxx> wrote:

Zhasper> find . -name "<junkfile>" -print0 | xargs -0 rm


Actually lighter weight, less forking less execing, because this
version runs two procsses only, rather than a new invocation of rm for
each file found.


It runs at least three processes if it finds any file - "rm" is forked from
xargs (unless xargs is smart enough to save the fork on end of input?)

But anyway - you can save yourself xargs in this case:

$ find -name "<junkfile>" -delete

should do the trick.

(It's funny what you can find from reading the various GNU utilities manual
pages (especially while trying to help people on Linux users mailing list to
troubleshoot stuff), I used to do recursive grep with "find | xargs grep"
until I learned about "grep -r", now I can stop using "find | xargs rm"
because I learned about "find ... -delete").

Cheers,

--Amos