How do I combine multiple grep commands?
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?
Another option:
... | grep -v -e @param -e @return -e @Test -e @throws
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)'
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