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:
Regex for “or” in grep

How can I grep for lines with either 'disable' or 'enable' in my file?

I tried $ grep "disable|enable" fail.log

but that shows up nothing.

share|improve this question

marked as duplicate by soandos, Dennis, slhck, Daniel Andersson, Doug Harris Jun 14 '12 at 15:19

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 2 down vote accepted

You need the -P switch for Perl Compatible Regular Expressions (PCRE).


grep -P "disable|enable" fail.log

Without it, grep uses POSIX Basic Regular Expressions, which have inconsistent escaping and less features.

share|improve this answer

Try "grep "disable\|enable" fail.log

The backslash turns the | into the "or" metacharacter, otherwise you are grepping for the literal 'disable|enable"

share|improve this answer

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