4 ms·
...except, that you should rarely use it. :) It is much, much faster to pipe commands to "xargs". For instance: find . -name core -print0 | xargs -0 rm -
by makecheck 17y ago
...except, that you should rarely use it. :)
It is much, much faster to pipe commands to "xargs". For instance:
find . -name core -print0 | xargs -0 rm -f
Since "find" doesn't know when your command is multi-file, it has to run the command once per file; whereas, "xargs" can run it as few times as necessary. It works well for any command that accepts "a list of files".
In the example above, the -print0/-0 are a safety net to null-delimit filenames so that it doesn't matter if any of the paths contains a space.
- spahl 17y ago...except, when I want to execute a command once per file. :-) If I want this I have the choice between: '-exec sed -i s/a/b/g {} \;' in find or '| xargs -IX sed -i s/a/b/g X'
- gaius 17y agoAlso the -n and -P options to xargs. So you would do something like $ find . -name 'blah*' |wc -l 2000 $ find . -name 'blah*' |xargs -n 250 -P 8 ./mangle That'll spawn 8 copies of mangle, each with 250 blah files on its command line.