1

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.

0

2 Answers 2

2

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.

2

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

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

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