News for hackers. Stuff that matters.
Re:Awesome but commonly unknown Linux Commands by michaelcampbell on Wednesday August 10, 2011 @10:36AM (#2868384)
With gnu tools, at least, xargs has a "-0" option to go hand in hand with gnu find's "-print0" option which obviates the spaces problem.

xargs is "better" in that it spawns 1 new process for however many things are found. -exec spawns 1 new process for EVERY thing found.

So:

    find . -name '*.log' -exec rm {} \;
spawns an rm for every log file.

    find . -name '*.log' -print0 | xargs -0 rm
spawns 1 rm for MANY log files. (Yes, I know zsh can do stuff like this too.)

xargs also has options to limit command line length or # of items if you want to limit that. find -exec is about the same then as find ... | xargs -n1

There are no comments on this comment yet.