I would like to select lines which do not match the specified pattern, where I have multiple patterns to exclude. As an example, I want to exclude lines which start with the keywords
$ grep -v '^apple' foo.txt | grep -v '^banana' -
I'm wondering if there's a way to do it with one expression or one call to
grep. I have tried the following, but they don't seem to work as hoped:
$ grep -v "^apple" -v "^banana" foo.txt $ grep -v "^(apple|banana)" foo.txt $ grep -v "(^apple)|(^banana)" foo.txt
What is a correct way to exclude multiple patterns?