Page 1 of 1
Grep -- how do I ignore .svn directories?
Posted: Sun Nov 30, 2008 11:18 pm
by alex.barylski
Code: Select all
"grep -RnH '$what' $PROJECT_FIND_PATH "
I need the line numbers and such that grep offers (unless find does too?) the the results are expected in 'grep' format so find won't work unless it returns the results *exactly* the same...
I need to somehow ignore .svn directories -- possible?
Cheers,
Alex
Re: Grep -- how do I ignore .svn directories?
Posted: Mon Dec 01, 2008 3:09 am
by VladSun
As you know, you can always use
find instead of
grep -R
Code: Select all
grep -nH $what `find '$where' -wholename '*/.svn*' -prune -o -print -type f`
Re: Grep -- how do I ignore .svn directories?
Posted: Mon Dec 01, 2008 7:28 pm
by alex.barylski
Dude...your the man.
Awesome...but I assume $where is project path?
Killer stuff...thanks again

Re: Grep -- how do I ignore .svn directories?
Posted: Sat Dec 06, 2008 4:38 pm
by Chris Corbyn
I usually just do this:
Code: Select all
grep something /path | grep -v .svn
grep does have an --exclude=pattern option too.
Re: Grep -- how do I ignore .svn directories?
Posted: Sat Dec 06, 2008 7:17 pm
by VladSun
It's a too much resource consuming solution

I mean -
grep for a text is slower than pre-excluding directories not to be searched by using
find.
And I'm not sure whether the
--exclude=PATTERN option will match against full path string or file name string.
Re: Grep -- how do I ignore .svn directories?
Posted: Wed Mar 31, 2010 7:44 pm
by bottomless
Use a recent version of grep (2.5.3 or better) so you can use the --exclude-dir switch that does work as expected:
http://blog.bottomlessinc.com/2008/06/i ... -searches/