egrep "foo|bar" *.txt
или
grep "foo\|bar" *.txt
grep -E "foo|bar" *.txt
выборочно цитируя страницу справочника гну-grep:
-E, --extended-regexp
Interpret PATTERN as an extended regular expression (ERE, see below). (-E is specified by POSIX.)
Matching Control
-e PATTERN, --regexp=PATTERN
Use PATTERN as the pattern. This can be used to specify multiple search patterns, or to protect a pattern
beginning with a hyphen (-). (-e is specified by POSIX.)
(...)
grep understands two different versions of regular expression syntax: “basic” and “extended.” In GNU grep, there
is no difference in available functionality using either syntax. In other implementations, basic regular
expressions are less powerful. The following description applies to extended regular expressions; differences for
basic regular expressions are summarized afterwards.
В начале я не читал далее, таким образом, я не распознал тонкие различия:
Basic vs Extended Regular Expressions
In basic regular expressions the meta-characters ?, +, {, |, (, and ) lose their special meaning; instead use the
backslashed versions \?, \+, \{, \|, \(, and \).
Я всегда использовал egrep и напрасно parens, потому что я извлек уроки из примеров. Теперь я изучил что-то новое.:)
Этот ответ для архитектуры IA-32. Я принял информационную форму Руководства Разработчика программного обеспечения Архитектуры Intels IA-32, Страница 1751/3044 (!):
Таблица 4-6. Формат 32-разрядной Записи Таблицы страниц, который Карты 4 кбайта Page: