Exclude .svn directories from grep


Question

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?

1
188
8/28/2015 1:17:38 PM

Accepted Answer

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/*" 
267
1/4/2012 11:52:30 PM

For grep >=2.5.1a

You can put this into your environment (e.g. .bashrc)

export GREP_OPTIONS='--exclude-dir=".svn"'

PS: thanks to Adrinan, there are extra quotes in my version:

export GREP_OPTIONS='--exclude-dir=.svn'

Licensed under: CC-BY-SA with attribution
Not affiliated with: Stack Overflow
Icon