grep: grep Programs
1
1 2.4 ‘grep’ Programs
1 ===================
1
1 ‘grep’ searches the named input files for lines containing a match to
1 the given pattern. By default, ‘grep’ prints the matching lines. A
1 file named ‘-’ stands for standard input. If no input is specified,
1 ‘grep’ searches the working directory ‘.’ if given a command-line option
1 specifying recursion; otherwise, ‘grep’ searches standard input. There
1 are four major variants of ‘grep’, controlled by the following options.
1
1 ‘-G’
1 ‘--basic-regexp’
1 Interpret the pattern as a basic regular expression (BRE). This is
1 the default.
1
1 ‘-E’
1 ‘--extended-regexp’
1 Interpret the pattern as an extended regular expression (ERE).
1 (‘-E’ is specified by POSIX.)
1
1 ‘-F’
1 ‘--fixed-strings’
1 Interpret the pattern as a list of fixed strings (instead of
1 regular expressions), separated by newlines, any of which is to be
1 matched. (‘-F’ is specified by POSIX.)
1
1 ‘-P’
1 ‘--perl-regexp’
1 Interpret the pattern as a Perl-compatible regular expression
1 (PCRE). This is experimental, particularly when combined with the
1 ‘-z’ (‘--null-data’) option, and ‘grep -P’ may warn of
1 unimplemented features. ⇒Other Options.
1
1 In addition, two variant programs ‘egrep’ and ‘fgrep’ are available.
1 ‘egrep’ is the same as ‘grep -E’. ‘fgrep’ is the same as ‘grep -F’.
1 Direct invocation as either ‘egrep’ or ‘fgrep’ is deprecated, but is
1 provided to allow historical applications that rely on them to run
1 unmodified.
1