Skip to main content

Firstly, you need to use quotingquotes for special characters. Second, even so, grep will not understand alternation directly; you would need to use egrep, or (with GNU grep only) grep -E.

egrep 'foo|bar' *.txt 

(The parentheses are unnecessary unless the alternation is part of a larger regex.)

Firstly, you need to use quoting for special characters. Second, even so grep will not understand alternation directly; you would need to use egrep, or (with GNU grep only) grep -E.

egrep 'foo|bar' *.txt 

(The parentheses are unnecessary unless the alternation is part of a larger regex.)

Firstly, you need to use quotes for special characters. Second, even so, grep will not understand alternation directly; you would need to use egrep, or (with GNU grep only) grep -E.

egrep 'foo|bar' *.txt 

(The parentheses are unnecessary unless the alternation is part of a larger regex.)

Source Link
geekosaur
  • 32.9k
  • 5
  • 84
  • 59

Firstly, you need to use quoting for special characters. Second, even so grep will not understand alternation directly; you would need to use egrep, or (with GNU grep only) grep -E.

egrep 'foo|bar' *.txt 

(The parentheses are unnecessary unless the alternation is part of a larger regex.)