I am using grep to filter out directories I am not interested in like this:

svn stat | grep -v data/charts | grep -v lib/model | grep -v web/pics

It seems a bit "hacky". Is there a better way to specify more than one string to ignore, so that I dont have to chain multiple grep commands?

link|improve this question

70% accept rate
feedback

3 Answers

up vote 1 down vote accepted

You can do svn stat | grep -vE 'data/charts|lib/model|web/pics'

You may also be interested in looking at grep -x. ack might be another tool of interest to you.

link|improve this answer
This is the command that works for me – morpheous Jul 29 '10 at 19:29
feedback

You can use disjuction with grep. Its the pipe symbol like in many regexes but you have to escape it since bash interprets it as actual pipe. Try this:

svn stat | grep -v data/charts\|lib/model\|web/pics
link|improve this answer
feedback

Or use grep -f, and put the list of patterns into a file. (That's most convenient if the list of things is fairly constant, of course.) grep -vf works fine, and inverts the sense of the matching just like regular grep -v. Just make sure you don't have any blank lines in the file full of patterns, because they'll match everything!

link|improve this answer
feedback

Your Answer

 
or
required, but never shown

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