LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   grep CLI syntax: how to find A OR B? (https://www.linuxquestions.org/questions/linux-newbie-8/grep-cli-syntax-how-to-find-a-or-b-519982/)

Kropotkin 01-16-2007 07:35 PM

grep CLI syntax: how to find A OR B?
 
I can't get figure out how to alternation to work on the command line. Something like this doesn't work:

$ grep \(the\|and\) somefile.txt

nor this:

$ grep "(the|and)" somefile.txt

What's the secret?

anomie 01-16-2007 07:44 PM

Try:
Code:

egrep 'the|land' somefile

matthewg42 01-16-2007 09:09 PM

What anomie said, or you could try:
Code:

grep -e the -e and somefile.txt

Kropotkin 01-16-2007 09:45 PM

Just what I was looking for, thanks.


All times are GMT -5. The time now is 08:24 PM.