Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

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.

2 Answers 2

up vote 2 down vote accepted

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

Try:

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 or ask your own question.