egrep

A variation of the grep command is egrep, which stands for extended grep. egrep extends the basic functions of grep by providing full regular expressions. Full regular expressions are more complex regular expressions that can do the following:

  • Search for several patterns at a time in an either-or condition

  • Use a file containing patterns as the basis for its search

egrep uses the same set of regular expression metacharacters for its search patterns as grep, but egrep also includes the following additional metacharacters:

  • str1|str2 Use the pipe (|) to match str1 or str2

  • () Treat the text as a group

Here’s how they work. In the following example, I’ll use egrep to search for two different patterns at once, as follows:

 egrep 'bcalkins|sburge' ...

Get Inside Solaris™ 9 now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.