Recursive grep that ignores svn

July 28th, 2008 by Hang

grep is a nice little tool which oddly doesn’t have the -R argument like every other linux utility to recursively search through sub directories. Google reveals that it’s possible to couple find with grep to simulate recursiveness however, a major annoyance with using recursive grep on a SVN project is that you get duplicates from the .svn folder.

This little alias creates a recursive grep that ignores the .svn directory.

In your .bashrc, add the line:

alias rgrep="find . -follow \( -name ".svn" \) -prune -o -print | xargs grep -Hn"

Logout and log back in again and rgrep foo should find foo in the current directory and all sub directories

Also featured in blogs: Developer
| Comments (0)