egrep - search a file for a pattern using full regular expressions
/usr/bin/egrep [-bcHhilnqsvx] -e pattern_list [-f file]
/usr/bin/egrep [-bcHhilnqsvx] [-e pattern_list] -f file
/usr/bin/egrep [-bcHhilnqsvx] pattern [file...]
) utility searches files for a pattern
of characters and prints all lines that contain that pattern. egrep
uses full regular expressions (expressions that have string values that use
the full set of alphanumeric and special characters) to match the patterns. It
uses a fast deterministic algorithm that sometimes needs exponential space.
If no files are specified, egrep
assumes standard input. Normally, each
line found is copied to the standard output. The file name is printed before
each line found if there is more than one input file.
utility accepts the same form of full regular expressions as
(1) -E option.
Be careful using the characters $
, and \
in full regular expression
they are also meaningful to the shell. It is safest to enclose the entire
full regular expression
in single quotes
The order of precedence of operators is 
, then *?+
concatenation, then | and NEWLINE.
The following options are supported:
Precede each line by the block number on which
it was found. This can be useful in locating block numbers by context (first
block is 0).
Print only a count of the lines that contain
Search for a pattern_list (full
regular expression that begins with a −).
Take the list of full regular
expressions from file.
Precedes each line by the name of the file
containing the matching line.
Suppress printing of filenames when searching
Ignore upper/lower case distinction during
Print the names of files with matching lines
once, separated by NEWLINEs. Does not repeat the names of files when the
pattern is found more than once.
Precede each line by its line number in the
file (first line is 1).
Quiet. Does not write anything to the standard
output, regardless of matching lines. Exits with zero status if an input line
Legacy equivalent of -q.
Print all lines except those that contain the
Consider only input lines that use all
characters in the line to match an entire fixed string or regular expression
to be matching lines.
The following operands are supported:
A path name of a file to be searched for the
patterns. If no file operands are specified, the standard input is
Specify one or more patterns to be used during
the search for input. This operand is treated as if it were specified as
(5) for the description of the behavior of egrep
encountering files greater than or equal to 2 Gbyte ( 2^31 bytes).
(5) for descriptions of the following environment variables
that affect the execution of egrep
, and NLSPATH
The following exit values are returned:
If any matches are found.
If no matches are found.
For syntax errors or inaccessible files (even
if matches were found).
(5) for descriptions of the following attributes:
Ideally there should be only one grep
command, but there is not a single
algorithm that spans a wide enough range of space-time trade-offs.
Lines are limited only by the size of the available virtual memory.
utility is identical to /usr/bin/grep
. See grep
(1). Portable applications should use
In the past the behavior of /usr/xpg4/bin/egrep
utilities was different. Now /usr/bin/egrep
is replaced by