Bob Dunlop wrote:
On Wed, Feb 02 at 03:42, Joakim Tjernlund wrote:
e.g. What does "rm -f /tmp/*" do if there are 12,000,000
files in the /tmp directory?  (Hint: nothing good!)
Whereas "find /tmp -mindepth 1 -maxdepth 1 ! -type d -print0 \
              | xargs -r0 rm -f" will succeed.  More
complicated, to be sure, but more robust.
In this case I guess
 find /tmp -mindepth 1 -maxdepth 1 ! -type d -exec rm -f {} \;

would work just as well and is less complicated or am I missing something?

I'm not 100% sure your find will cope with a filename with spaces in it.
Might be a portability issue if nothing else.

The big difference is the xargs version will group files together making
far fewer calls to rm whereas your version invokes a new rm for each file.
That could be a big efficiency hit if there are truely large numbers of
files involved.
Filenames with spaces should work with -exec.

Newer versions support "-exec cmd {} +" instead of "-exec cmd {} ;", which behaves like xargs, it will run the command with multiple filenames.

Ralf Friedl
_______________________________________________
busybox mailing list
[email protected]
http://lists.busybox.net/mailman/listinfo/busybox

Reply via email to