Take the 2-minute tour ×
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free, no registration required.

So I have a project under svn and I'm searching the file contents. In the result set I get .svn files that I don't want actually to see. for example:

$ grep -i -r "breadcrumb" . -l
./terms_and_conditions/.svn/text-base/index.tpl.svn-base
./terms_and_conditions/.svn/tmp/index.tpl.tmp 
./terms_and_conditions/.svn/tmp/index.tpl.3.tmp
./terms_and_conditions/.svn/tmp/index.tpl.2.tmp
./terms_and_conditions/index.tpl
./privacy/.svn/text-base/index.tpl.svn-base
./privacy/.svn/tmp/index.tpl.tmp
./privacy/.svn/tmp/index.tpl.3.tmp
./privacy/.svn/tmp/index.tpl.2.tmp
./privacy/index.tpl

how can I exclude the files under ".svn" directories from the result set so that I only get

./terms_and_conditions/index.tpl
./privacy/index.tpl
share|improve this question
add comment

1 Answer 1

up vote 5 down vote accepted

Pipe those through:

grep -v '/\.svn/'
share|improve this answer
    
Works like a charm. But why '/\.svn/' and not ".svn"? –  Jon Doe Nov 12 '10 at 4:05
    
You could simply use "svn"; it's not likely that you've used svn in your file names. –  Nerdling Nov 12 '10 at 6:11
    
@Joe If you don't surround it by slashes or have the dot, it could match other things with "svn" in their path... And @Nerdling I don't see the value in not matching accurately when it's so easy, however unlikely. –  Oli Nov 12 '10 at 10:04
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.