in reply to Re: Receiving Standard Input/Piped
in thread Receiving Standard Input/Piped

of course... =P
So xargs just opens up standard input, reads data, reads a file per line as default and calls an instance of the following program with a command line argument of one of the files for each file.
I was trying to think of any other programs that do this in one go and can process standard input as arguments also (inherant xargs), but couldn't come up with any.
The closest thing I could think of that I use...
find -name "*.h" -exec grep "search word" {} \; -print
looks like its just the same thing, once find has all the files, call and instance of grep with a single argument.
Anyways thanks for your help, thats what I needed =).

Regards Paul.

Replies are listed 'Best First'.
Re^3: Receiving Standard Input/Piped
by sk (Curate) on Sep 08, 2005 at 16:14 UTC
    So xargs just opens up standard input, reads data, reads a file per line as default and calls an instance of the following program with a command line argument of one of the files for each file.

    Actually xargs can-call/calls the program with multiple args. You can also specify the number of args using -n switch

    people prefer xargs because it avoids the Argument list too long problem. Also the -exec is not as efficient as xargs because it calls the prog each time it finds a file while xargs knows how big is OK and calls it accordingly! i.e. fewer calls to the prog

    cheers

    SK