[KLUG Members] recursive directory searches without grep

Peter Buxton members@kalamazoolinux.org
Tue, 28 Aug 2001 13:11:00 -0400


On Tue, Aug 28, 2001 at 12:47:01PM -0400, Patrick McGovern was only 
   escaped alone to tell thee:

> My linux box supports the -r option with grep to search directories
> recursively.  My Unix box does not support this option for grep.
> 
> Does anyone know of a replacement for the grep -r  command.  I will be
> using this in a Korn shell script.

Feed the filenames to grep with find(1). find is a little steep on the
learning curve, but well worth the effort.

find . -name 'foo*' -exec grep 'regexp' \{\} \;

finds all files foo* in the tree starting in your current dir and runs the
grep command given on each one. There are more efficient ways to do this
command, I'm sure.