When I try to do grep search looking for pattern 1 OR pattern 2 it doesn't work. Ex:
grep -e a|b file.txt
Should find lines that have either a or b in them.
Doesn't work. NT cmd pukes on the | character. So I try to escape it with ^| as in:
grep -e a^|b file.txt
Still doesn't work.
I can do multi -e patterns as in:
grep -e a -e b file.txt
Shouldn't the | symbol work however?
> grep -e a^|b file.txt
> Still doesn't work.
Use the double quotes around expressions that contain the pipe (|) or the redirection arrows (>, <), and also prefix the pipe with a backslash. This will work on Windows NT/2K/XP:
grep "a\|b" file.txt
egrep "a|b" file.txt
Log in to post a comment.
Sign up for the SourceForge newsletter:
You seem to have CSS turned off.
Please don't fill out this field.