
* Oliver Jones <oliver(a)deeperdesign.com> [2005-08-15 16:10]:
You want to pipe `find ... -print0` to something, most of the time. (Usually xargs(1). That’s much faster than spawning one process for every single file, too, even for a pretty small number of files.)
xargs is only useful for feeding commands that accept multiple files as arguments and do the same thing to each file (eg cat).
That’s why I said “usually.” :-) Sometimes, you want to pipe the input to something else. What I was emphasizing is that find(1)’s `-print0` predicate avoids any quoting problems simply by delimiting filenames using the only character that can’t be part of a filename. You can then do anything you want with the output without running into quoting problems; xargs(1) is only one choice for processing it, but the most common because it covers many simple uses.
On a small number of files/lines xargs is likely to only execute the target command once.
Exactly, that’s why it’s useful to reduce the overhead as compared to find(1)’s `-exec` predicate, which always executes the command as many times as there are files. Regards, -- Aristotle Pagaltzis // <http://plasmasturm.org/>