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 tuatha.org [mailto:valen at 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
>
Maintained by the ILUG website team. The aim of Linux.ie is to
support and help commercial and private users of Linux in Ireland. You can
display ILUG news in your own webpages, read backend
information to find out how. Networking services kindly provided by HEAnet, server kindly donated by
Dell. Linux is a trademark of Linus Torvalds,
used with permission. No penguins were harmed in the production or maintenance
of this highly praised website. Looking for the
Indian Linux Users' Group? Try here. If you've read all this and aren't a lawyer: you should be!