Alternatives are defined with the binary OR metacharacter, the pipe |
This will find either bob or sam:
1 |
egrep 'bob|sam' text.txt |
Subexpressions can be defined with parenthesis metacharacters to limit scope
This will find submarine and subclipse:
egrep ‘sub(marine|clipse)’ test.txt