Exclude .svn directories from grep

Kees Kist picture Kees Kist · Sep 29, 2009 · Viewed 59.7k times · Source

When I grep my Subversion working copy directory, the results include a lot of files from the .svn directories. Is it possible to recursively grep a directory, but exclude all results from .svn directories?

Answer

psychoschlumpf picture psychoschlumpf · Sep 29, 2009

If you have GNU Grep, it should work like this:

grep --exclude-dir=".svn"

If happen to be on a Unix System without GNU Grep, try the following:

grep -R "whatever you like" *|grep -v "\.svn/*"