Date: Thu, 13 Nov 2003 18:15:06 -0500 (EST) From: Jerry McAllister <jerrymc@clunix.cl.msu.edu> To: patterner@rocketmail.com Cc: FreeBSD Questions List <questions@freebsd.org> Subject: Re: Recursion with grep? Message-ID: <200311132315.hADNF7H12071@clunix.cl.msu.edu> In-Reply-To: <20031113225534.69670.qmail@web40611.mail.yahoo.com> from "Chris Readle" at Nov 13, 2003 02:55:34 PM
next in thread | previous in thread | raw e-mail | index | archive | help
> > --- Matthew Hunt <mph@astro.caltech.edu> 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 > > chris Not as elegant maybe, but you can also do something like ls -li string *.c ls -li string */*.c ls -li string */*/*.c etc... Using the shells uparrow to repeat the command makes that easy if you only have a few directory levels to peruse. ////jerry
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200311132315.hADNF7H12071>