How to use grep to search for multiple options

How can I use grep to search for line with either 'res' or 'rep'?

i try "grep -e res|rep" or gre -e "rep|rep" but that does not work.


Solution 1:

You can also use -E option with grep, so there's no need to escape "|", for example:

grep -E 'res|rep' file

Or, you can use egrep, which is the same thing as grep -E:

egrep 'res|rep' file

Solution 2:

You need to escape the pipe character:

grep 'res\|rep' file

or use multiple -e options:

grep -e 'res' -e 'rep' file