----- Original Message -----
From: "Anders Johansson"
On Wed, 2008-03-26 at 21:21 +0100, Per Jessen wrote:
Randall R Schulz wrote:
% find dirName(s) {findCriteria} -print0 |xargs -0 rm
By doing this, xargs essentially "batches up" maximal (w.r.t. the argument size limit) sets of file names and invokes rm only as many times as necessary.
Randall, that has got to be one of the coolest pieces of advice I've seen here. "man xargs" doesn't even mention it.
huh? It's what xargs does. It's the basic functionality of the program
Anders
Bizarrely, he's right though. The man page (at least on linux at least on suse) doesn't quite say what the point is. It says it "builds command lines from stdin" but that doesn't mean very much. It doesn't actually say the two crucial parts about: 1) up to the limit if the shell or system or the application 2) re-executing as necessary, indefinitely, until input is exhausted It is a funny sort of a blind spot. 99.99% of people who read the page, and obviously the author too, do not notice the lack bcause we all just know what xargs is for somehow from some other source. In my case because the SCO Xenix man page for xargs was of better quality. :) I don't remember it exactly but I'm pretty sure that was where I first encountered xargs and the purpose of the util was made clear. The current SCO Open Server 5.0.7 man page is probably the same and says, among other useful things: "When no options are coded, the initial-arguments are followed by arguments read continuously from standard input until an internal buffer is full, and command is executed with the accumulated arguments. This process is repeated until there are no more arguments. When there are option conflicts (for example, -l and -n), the last specified option has precedence." You might say "why would you man xargs unless you already knew you needed xargs, and thus, what xargs was for?" Lots of reasons. Starting with: "This script is running xargs. Why?" "Some dude/magazine/etc... told me to run blah |xargs blah. What will that do?" It should also be noted that it's also useful for iterating through arbitrarily large lists one item at a time instead of accumulating large command lines. When I say "or the application" above that means, maybe the limit is just one filename argument per invcation because app foo can only handle one file at a time. (like say, vorbiscomment) xargs -n 1 will do that. The point of xargs isn't really to accumulate large command lines, but rather to handle input of unknown/unlimited size and chunk it into command lines of whatever size is needed, which may just as easily be one item as MAXCARGS. -- Brian K. White brian@aljex.com http://www.myspace.com/KEYofR +++++[>+++[>+++++>+++++++<<-]<-]>>+.>.+++++.+++++++.-.[>+<---]>++. filePro BBx Linux SCO FreeBSD #callahans Satriani Filk! -- To unsubscribe, e-mail: opensuse+unsubscribe@opensuse.org For additional commands, e-mail: opensuse+help@opensuse.org