Recursion with grep?

Chris Readle patterner at
Thu Nov 13 14:55:36 PST 2003

--- Matthew Hunt <mph at> wrote:
> On Thu, Nov 13, 2003 at 05:37:39PM -0500, 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
> > 
> > I get no files. However, if I go into one of the subdirectories and do
> a
> > plain grep <string> *.c then <string> is found on several files.
> When using "-r", the arguments to grep should be directories.  It will
> process all of the files in the given directories, recursively.  There
> is
> no provision for searching a subset of the files (i.e. "*.c).  If you
> need to do that, use find and xargs.

You can also do this with something like:

ls -laR | egrep *.c


Do you Yahoo!?
Protect your identity with Yahoo! Mail AddressGuard

More information about the freebsd-questions mailing list