From: Padraig Brady (Padraig.Brady at domain digital.com)
Date: Fri 27 Aug 1999 - 10:23:28 IST
There is a compile time limit on the length
of the command line which can easily be exceeded
when using a construct like:
grep word `find . -name '*' `
What you want is to break the list of files up
to the max command line length and run the command
multiple times on these sublists, which is what
xargs does.
It will take input from stdin and tack the
"sublists" on end of each command line.
Therefore:
find /dir/to/start/from -name "*" | xargs grep "word"
will cause the shell to start at least 3 processes concurrently...
find sending stdout to stdin of xargs, and xargs will
exec() the required amount of grep instances to deal
with all the input. Very elegant..
Note you can get find to -exec{} grep for each
file it finds instead of using xargs, but this will
fire off a grep process FOR EVERY file found which
is serious overhead.
> -----Original Message-----
> From: valen at domain tuatha.org [mailto:valen at domain tuatha.org]
>
> On Thu, Aug 26, 1999 at 04:51:06PM +0100, Padraig Brady mentioned:
> > > Maybe rgrep -r is what you want.
> > find . -name '*' | xargs grep "word"
>
> Right. What's the story with xargs. What's wrong with;
>
> $ grep word `find . -name '*' `
>
> I've **never** had to use xargs....
>
> Kate
>
This archive was generated by hypermail 2.1.6 : Thu 06 Feb 2003 - 13:04:30 GMT