Recursion with grep?

Viktor Lazlo viktorlazlo at telus.net
Thu Nov 13 18:32:44 PST 2003



On Thu, 13 Nov 2003, Dan Busarow wrote:

> On Nov 13, Francisco Reyes wrote:
> > The man page for grep says to use "-r" to recurse, yet when I try
> > something like
> >
> > grep -r -li string *.c
>
> find . -name "*.c" -exec grep -li string {} \;

If there are a large number of files this will call grep numerous
times--it would be more efficient to pass to xargs so grep is only called
a few times:

find . -type f -print | xargs grep options string

Cheers,

Viktor


More information about the freebsd-questions mailing list