grep Programs (GNU Grep 3.7)
2.4 grep Programs
grep searches the named input files for lines containing a match to the given patterns. By default,
grep prints the matching lines. A file named
- stands for standard input. If no input is specified,
grep searches the working directory
. if given a command-line option specifying recursion; otherwise,
grep searches standard input. There are four major variants of
grep, controlled by the following options.
Interpret patterns as basic regular expressions (BREs). This is the default.
Interpret patterns as extended regular expressions (EREs). (
-Eis specified by POSIX.)
Interpret patterns as fixed strings, not regular expressions. (
-Fis specified by POSIX.)
Interpret patterns as Perl-compatible regular expressions (PCREs). PCRE support is here to stay, but consider this option experimental when combined with the
--null-data) option, and note that ‘
grep -P’ may warn of unimplemented features. See Other Options.
In addition, two variant programs
fgrep are available.
egrep is the same as ‘
fgrep is the same as ‘
grep -F’. Direct invocation as either
fgrep is deprecated, but is provided to allow historical applications that rely on them to run unmodified.