Regular Expressions in the Real World : egrep
The program "egrep" is an acronym for "extended global regular expressions print" and may be used to search for a string or a more complex pattern in a file. Regular expressions provide a convenient, compact way of expressing patterns. The internal workings of egrep are based on finite automata.
The command format is: egrep
regexp file
where file is a file name and regexp
is a regular expression whose format will be described shortly.
Egrep returns all strings in the file which match the regular
expression.
The format of a regular expression in egrep is as follows:
Try the following examples:
egrep depend /usr/dict/words
egrep ^y.*y$ /usr/dict/words
egrep y.*y /usr/dict/words
egrep ^rec(ei|ie)ve$ /usr/dict/words
egrep ^s..u.t..e$ /usr/dict/words
egrep (^| )the +the( |$) ~jillz/cs250/testfile