Limitations on a command line

Bob Dunlop bob.dunlop at xyzzy.org.uk
Wed Feb 2 17:10:54 UTC 2011


Hi,

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.

-- 
        Bob Dunlop


More information about the busybox mailing list