On Wed, Mar 18, 2009 at 10:05:08PM +0100, Jörg-Volker Peetz wrote: > kj wrote: > > Now, I've been running the usual find . -type f -exec rm {} \; > > but this is going at about 700,000 per day. Would simply doing an rm > > -rf on the Maildir be quicker? Or is there a better way? > > As already said, this calls rm for every file. Another alternative is with > newer > versions of find: > > find . -type f -exec rm {} \+ > > This calls rm for as many files as fit on the command line. > But probably "rm -rf" is the fastest.
the '+' behavior is exactly why people use xargs: find . -type f | xargs rm will not call rm N times for N files; rather, it will call rm in batches of as many arguments as it can reasonably fit in each call. to see for yourself, compare: $ find . -type f -exec echo CALL '{}' ';' $ find . -type f -exec echo CALL '{}' '+' $ find . -type f | xargs echo CALL $ find . -type f | xargs -n 1 echo CALL the number of times you see 'CALL' in the output is the number of 'rm' calls you'd get. --Rob* p.s. if you're chaining find and xargs and your filenames have spaces and such in them, you'll want to use -print0 and -0 for the find and xargs, repectively, to separate the filenames by ascii NULs instead of spaces: $ find . -name Sp\* ./Space Ghost Coast to Coast - table read.TiVo $ find . -name Sp\* | xargs ls -l ls: cannot access ./Space: No such file or directory ls: cannot access Ghost: No such file or directory ls: cannot access Coast: No such file or directory ls: cannot access to: No such file or directory ls: cannot access Coast: No such file or directory ls: cannot access -: No such file or directory ls: cannot access table: No such file or directory ls: cannot access read.TiVo: No such file or directory $ find . -name Sp\* -print0 | xargs -0 ls -l -rw-r--r-- 1 robstar robstar 753751465 2008-09-06 02:53 ./Space Ghost Coast to Coast - table read.TiVo -- /-------------------------------------------------------------\ | "If we couldn't laugh we would all go insane" | | --Jimmy Buffett, | | "Changes in Latitudes, Changes in Attitudes" | \-------------------------------------------------------------/ -- To UNSUBSCRIBE, email to debian-user-requ...@lists.debian.org with a subject of "unsubscribe". Trouble? Contact listmas...@lists.debian.org