[PLUG] Recursive grep

lemming at attbi.com lemming at attbi.com
Mon Sep 23 20:24:33 UTC 2002


Or you could do:

grep -r --include='*.c' "find.this.string"
Paul wrote:
> On Mon, 23 Sep 2002, Mike Witt wrote:
> 
> > When I want to grep through (for example) all the .c files in
> > a hierarchy I've been using find, for example:
> > 
> >   find . -name \*.c -exec fgrep -H "find.this.string" {} \;
> > 
> > It SEEMS like I ought to be able to accomplish the same thing using
> > grep recursively, something like: 
> > 
> >   grep -r "find.this.string" *.c
> 
> No, because -r == -d recurse, so grep reads all files under each 
> directory that matches the '*.c' expansion.
> 
> find's -exec option is expensive, however, so you can do a hacky sort 
> of combination to speed things up a bit:
> 
>   grep 'find.this.string' $(find . -name \*.c)




More information about the PLUG mailing list