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:
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' file1 <cr>
The following lines are displayed:
bcalkins Bill Calkins ext. 123 Engineering sburge Steve Burge ext. 234 IT
Multiple patterns can be supplied using multiple pipes. Another option with egrep is to put the search pattern into a file. I have a file named patterns that contains the following entries:
(bcalkins|wcalkins) (burge|Bill)
When included in a file, the search patterns do not require quotes, but you must enclose them in parenthesis. Now when I execute egrep, I supply the filename containing the search pattern as follows:
egrep –f patterns * <cr>
All files are searched, and the results are displayed as follows:
file1:bcalkins Bill Calkins ext. 123 Engineering file1:wcalkins William Calkins ext. 123 Engineering file1:sburge Steve Burge ext. 234 IT patterns:(bcalkins|wcalkins) patterns:(burge|Bill) userlist:bcalkins Bill Calkins ext. 123 Engineering userlist:sburge Steve Burge ext. 234 IT