[ILUG] Limits of grep?

Fergal Daly fergal at esatclear.ie
Wed Sep 27 22:25:10 IST 2000


At 12:00 26/09/00, Paul Kelly wrote:
>Subba Rao wrote:
> > I have a directory of 10000+ text files and would like to search for
> > some strings in these files. When I tried using "grep" command with an
> > asterisk...
>
>That's a shell issue as much as grep. Try find . -print | xargs grep
>"pattern"

This will go wrong on any file that has a space or a shell meta character 
and may even end abruptly. To avoid this use

find . -print0 | xargs -0 grep "pattern"

find will output the filenames in null separated format and xargs will 
expect them like that,

Fergal






More information about the ILUG mailing list