[PLUG] Recursive grep

Paul Heinlein heinlein at attbi.com
Tue Sep 24 13:50:37 UTC 2002


On Mon, 23 Sep 2002, Rich Shepard wrote:

> I've been using 'rgrep -r ...' under RH 6.2 with the 2.2 kernels. Is
> this something different?

Yeah. Using GNU grep 2.4.x and older, you couldn't (easily) tell grep,
"search for string 'foo' in all *.h files in the entire /usr/include
directory tree." The intuitive command,

  cd /usr/include
  grep -r foo *.h

wouldn't do what you really wanted[1]. Now, however, grep 2.5.x can do
it:

  cd /usr/include
  grep -r --include="*.h" foo *

--Paul Heinlein <heinlein at attbi.com>

[1] Because the shell, not grep, would handle the wildcard expansion. 
    So grep never even had a chance to guess at what you really wanted 
    to do.





More information about the PLUG mailing list