Open System Services Shell and Utilities Reference Manual (G06.25+, H06.03+)
Table Of Contents
egrep(1) OSS Shell and Utilities Reference Manual
NAME
egrep - Searches a file for a pattern that is a full regular expression
SYNOPSIS
egrep
[-c | -l]
[-bhinqsvx]
{ pattern ... | -e pattern ... | -f pattern_file ... }
[file ... ]
FLAGS
While most flags can be combined, some combinations result in one flag overriding another. For
example, if you specify both the -n and -l flags, the output includes only filenames (as specified by
the -l flag) and thus does not include line numbers (as specified by the -n flag).
-b Precedes each line by the block number of the block in which it was found. Use this flag
to help find disk block numbers by context.
-c Displays only a count of matching lines.
-e pattern ...
Specifies a pattern. This flag works the same as a simple pattern but is useful when the
pattern begins with a - (dash).
-f pattern_file ...
Specifies a file that contains patterns. Each pattern terminates with a newline character.
-h Suppresses reporting of filenames when multiple files are processed.
-i Ignores the case of letters in locating pattern; that is, uppercase and lowercase letters in
the input are considered to be identical.
-l Lists the name of each file that has lines matching pattern. Each filename is listed only
once; filenames are separated by newline characters.
-n Precedes each line with its relative line number in the file.
-q Suppresses all output except error messages. This flag is useful for easily determining
whether a pattern or string exists in a group of files. When searching several files, it pro-
vides a performance improvement, because it can quit as soon as it finds the first match,
and it requires less care by the user in choosing the set of files to supply as arguments,
because it exits with a 0 (zero) exit status if it detects a match, even if the egrep com-
mand detected an access or read error on earlier file arguments.
-s Suppresses error messages about inaccessible files.
-v Displays all lines except those that match the specified pattern. This flag is useful for
filtering unwanted lines out of a file.
-x Displays lines that match the pattern exactly with no additional characters.
DESCRIPTION
The egrep command searches the specified files (the standard input file by default) for lines con-
taining characters that match the specified pattern and then write matching lines to the standard
output file.
The egrep command is an obsolescent version of the command grep -E, which searches for pat-
terns that are full regular expressions, except for \( and \), and with the addition of the following
rules:
3−50 Hewlett-Packard Company 527188-003