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.

I have a command like this:

| grep -v @param | grep -v @return | grep -v @Test | grep -v @throws

and its getting bigger, is there any way to make this neater?

share|improve this question

3 Answers 3

up vote 12 down vote accepted

Another option:

... | grep -v -e @param -e @return -e @Test -e @throws
share|improve this answer

You can use:

... | grep -v "\(@param\|@return\|@Test\|@throws\)"

or you can use the -E flag to enable extended regular expressions, which will allow you to avoid escaping the parentheses and pipe characters:

... | grep -Ev '(@param|@return|@Test|@throws)'
share|improve this answer
@Barton Thank you for pointing that out! –  lgarzo Nov 22 '11 at 15:48

Alternatively, you can place all your patterns in a file, one pattern per line, and use

... | grep -v -f matches.txt

Would make things easier if you use the patterns regularly

share|improve this answer

Your Answer


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.