Ask Ubuntu is a question and answer site for Ubuntu users and developers. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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
up vote 13 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.