Submit Hint Search The Forums LinksStatsPollsHeadlinesRSS
14,000 hints and counting!

Click here to return to the 'A better use of find' hint
The following comments are owned by whoever posted them. This site is not responsible for what they say.
A better use of find
Authored by: rebar on Nov 28, '03 12:04:56PM

instead of using printf and xargs which will get upset if your directories have spaces or if you have a LOT of them, why not use -exec instead?


find . -name .DS_Store -ls -exec rm {} \;

the -ls will list them out just before they are removed.

This should work well on any modern UNIX. You can run just about anything like this; suppose you want to batch-encode all your aiff files or whatever, find is very powerful with the -exec argument.

[ Reply to This | # ]
A better use of find
Authored by: tiph on Nov 28, '03 12:59:08PM

The main reason is that -exec will be slower, since a rm process is started for each file, whereas xargs will invoke rm by batch.

[ Reply to This | # ]
A better use of find
Authored by: durin on Nov 28, '03 05:08:09PM

using xargs doesn't break with spaces in the names(look carefully, I enclosed the path in quotes), and it is probably a little faster because only one rm is spawned, instead of one per file.


Go not to the elves for council, they will say both no and yes

[ Reply to This | # ]