Super User is a question and answer site for computer enthusiasts and power users. 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

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'
share|improve this question

marked as duplicate by JdeBP, random Dec 5 '11 at 2:21

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

up vote 6 down vote accepted

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

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

or, shorter:

grep -vE '(word1|word2)'
share|improve this answer
Excellent! Thanks. – Vladimir Nov 21 '11 at 10:18
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)'` – RedGrittyBrick Nov 21 '11 at 15:22

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