More about regular expressions


grep is just one of a family of commands that use regular expressions. egrep provides some more sophisticated regular expression features (and there is also an fgrep that does not do regular expression searching at all, ostensibly to be faster for simple substring searching).

The major regular expression extensions provided by egrep (and also available in some other tools that handle regular expressions) are:

+
Match one or more of the previous match.
?
Match zero or one of the previous match.
(re)
Match re.
(re1|re2)
Match either re1 or re2.

There are also some commonly-used options to the grep-family commands:

-i
Do case-insensitive matching (a == A).
-v
Print only lines that don't match the regular expression.
-l
Print names of files containing matches, not matching lines from those files.
-c
Print a count of matching lines for each file.

As usual, man grep will give you a much more detailed listing of available options.

Next ->


Steve VanDevender
Last modified: Thu Jul 26 14:46:25 PDT 2007