16

I have a command like this:

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

And it's getting bigger. Is there a way to make this neater?

3 Answers 3

18

Another option:

... | grep -v -e @param -e @return -e @Test -e @throws
10

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)'
0
8

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

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .