On Wed, 31 May 2000, Thomas Lockhart wrote:

> > -> ... All I want to do is search all the *.c file
> > -> recursively starting from a specific directory for a specific string...
> > -> grep -r -e "function something" -f *.c
> > I'd start with:
> > grep -i "function" *.c
> 
> The above will search all .c files in the current directory, but will
> not descend the tree. Using -r will not likely help, since the shell
> will expand the "*.c" in the current directory before grep ever sees the
> command line.
> 
> I usually use something like:
> 
> find . -name '*.c' -exec egrep 'regexp' {} \; -print
> 
> where the "-print" will show you which file had the matching string(s).

i tend to prefer;

   find . -name \*.c -exec grep 'string' {} /dev/null \;

as grep when given more than one file prints the filename at
the beginning of the matching line (the second file  here is
/dev/null which won't match). i find it a little easier to
read, and it also helps if you want to further pipe the
output to awk or something such...


                                         ...joakim


Reply via email to