Grep multiple files but exclude .svn (subversion) directories
The --exclude flag described below does not work.
This does:
grep -nHR 'needle' . | grep -v svn
from http://episteme.arstechnica.com/eve/forums/a/tpc/f/6330927813/m/902005657831
grep exclude .svn
Setting $GREP_OPTIONS in ~/.bashrc like this did the trick
export GREP_OPTIONS="--exclude="\*/.svn/\*"At 11:41 AM -0400 4/11/04, Stephen Peters wrote:
>Brad Cox writes:
>
>> #1 on the wish list: what is the svn-friendly way to use grep -r foo
>> src to find all the foos in my working src directory, without
>> interference from hits in svn's administrative area (.svn). Hopefully
>> a global setting somewhere so I don't have to type special commands
>> each time. There are hopeful prospects in the man pages but I've not
>> yet hit on a working combination.
>
>I've made use of
> alias rg='grep --exclude=\*.svn\* -r'
>
>And then was able to type
> rg foo src
[forgot URL]
http://snippets.dzone.com/posts/show/3707
grep -r PATTERN * | grep -v '/.svn/'
More grep:
http://www.ss64.com/bash/grep.html
http://www.computerhope.com/unix/uegrep.htm
The --exclude flag described below does not work.
This does:
grep -nHR 'needle' . | grep -v svn
from http://episteme.arstechnica.com/eve/forums/a/tpc/f/6330927813/m/902005657831
grep exclude .svn
Setting $GREP_OPTIONS in ~/.bashrc like this did the trick
export GREP_OPTIONS="--exclude="\*/.svn/\*"At 11:41 AM -0400 4/11/04, Stephen Peters wrote:
>Brad Cox writes:
>
>> #1 on the wish list: what is the svn-friendly way to use grep -r foo
>> src to find all the foos in my working src directory, without
>> interference from hits in svn's administrative area (.svn). Hopefully
>> a global setting somewhere so I don't have to type special commands
>> each time. There are hopeful prospects in the man pages but I've not
>> yet hit on a working combination.
>
>I've made use of
> alias rg='grep --exclude=\*.svn\* -r'
>
>And then was able to type
> rg foo src
[forgot URL]
http://snippets.dzone.com/posts/show/3707
grep -r PATTERN * | grep -v '/.svn/'
More grep:
http://www.ss64.com/bash/grep.html
http://www.computerhope.com/unix/uegrep.htm
Comments
--exclude-dir works (since grep 2.5)
Grep 2.5 have a new option item --exclude-dir, it should work for you.
grep --exclude-dir=*/.svn/* --exclude=*~ pattern path/to/search/ -Rn
should work for you.
or set it in bash.rc
export GREP_OPTIONS="--exclude-dir=\*/.svn/\* --exclude=\*~"
check my blog :
http://bmmkevin.blogspot.com/
Post new comment