| [ << ] | [ < ] | [ Up ] | [ > ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
2.4 grep Programs
grep searches the named input files
(or standard input if no files are named,
or the file name ‘-’ is given)
for lines containing a match to the given pattern.
By default, grep prints the matching lines.
There are four major variants of grep,
controlled by the following options.
- ‘-G’
- ‘--basic-regexp’
-
Interpret the pattern as a basic regular expression (BRE). This is the default.
- ‘-E’
- ‘--extended-regexp’
-
Interpret the pattern as an extended regular expression (ERE). (‘-E’ is specified by POSIX.)
- ‘-F’
- ‘--fixed-strings’
-
Interpret the pattern as a list of fixed strings, separated by newlines, any of which is to be matched. (‘-F’ is specified by POSIX.)
- ‘-P’
- ‘--perl-regexp’
-
Interpret the pattern as a Perl regular expression. This is highly experimental and ‘grep -P’ may warn of unimplemented features.
In addition,
two variant programs egrep and fgrep are available.
egrep is the same as ‘grep -E’.
fgrep is the same as ‘grep -F’.
Direct invocation as either
egrep or fgrep is deprecated,
but is provided to allow historical applications
that rely on them to run unmodified.
| [ << ] | [ < ] | [ Up ] | [ > ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
This document was generated on November 17, 2011 using texi2html 5.0.
