5

Possible Duplicate:
Grep command, to remove lines containing a specified word

How do I grep for more than one words in one grep command. For example:

cat file.txt | grep -v 'word1' | grep -v 'word2'

to be transformed into something like:

cat file.txt | grep -v 'word1|word2'
0

1 Answer 1

6

Use -E for extended regular expressions, then you can use

grep -v -E '(word1|word2)'

or, shorter:

grep -vE '(word1|word2)'
1
  • 1
    If there's no search-text outside the brackets you can omit them: grep -vE 'word1|word2'. You only need brackets when you search for something like 'orang(es| utangs)'` Nov 21, 2011 at 15:22

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