|
|
coherent
egrep Command egrep
Extended pattern search
eeggrreepp [_o_p_t_i_o_n ...] [_p_a_t_t_e_r_n] [_f_i_l_e ...]
egrep is an extended and faster version of grep. It searches
each file for occurrences of pattern (also called a regular
expression). If no file is specified, it searches the standard
input. Normally, it prints each line matching the pattern.
***** Wildcards *****
The simplest patterns accepted by egrep are ordinary alphanumeric
strings. Like eedd, eeggrreepp can also process _p_a_t_t_e_r_n_s that include
the following wildcard characters:
^ Match beginning of line, unless it appears immediately after
`[' (see below).
$ Match end of line.
* Match zero or more repetitions of preceding character.
. Match any character except newline.
[_c_h_a_r_s]
Match any one of the enclosed chars. Ranges of letters or
digits may be indicated using `-'.
[^_c_h_a_r_s]
Match any character except one of the enclosed chars. Ranges
of letters or digits may be indicated using `-'.
\_c Disregard special meaning of character c.
***** Metacharacters *****
In addition, egrep accepts the following additional metacharac-
ters:
| Match the preceding pattern or the following pattern. For
example, the pattern cat|dog matches either cat or dog. A
newline within the pattern has the same meaning as `|'.
+ Match one or more occurrences of the immediately preceding
pattern element; it works like `*', except it matches at
least one occurrence instead of zero or more occurrences.
? Match zero or one occurrence of the preceding element of the
pattern.
(...)
Parentheses may be used to group patterns. For example,
(Ivan)+ matches a sequence of one or more occurrences of the
four letters `I' `v' `a' or `n'.
COHERENT Lexicon Page 1
egrep Command egrep
Because the metacharacters `*', `?', `$', `(', `)', `[', `]', and
`|' are also special to the shell sshh, patterns that contain
those literal characters must be quoted by enclosing pattern
within single quotation marks.
***** Options *****
The following lists the available options:
-bb With each output line, print the block number in which the
line started (used to search file systems).
-cc Print how many lines match, rather than the lines themselves.
-ee The next argument is pattern (useful if the pattern starts
with `-').
-ff The next argument is a file that contains a list of patterns
separated by newlines; there is no pattern argument.
-hh When more than one file is specified, output lines are norm-
ally accompanied by the file name; -h suppresses this.
-ll Print the name of each file that contains the string, rather
than the lines themselves. This is useful when you are con-
structing a batch file.
-nn When a line is printed, also print its number within the
file.
-ss Suppress all output, just return exit status.
-vv Print a line only if the pattern is not found in the line.
-yy Lower-case letters in the pattern match lower-case and upper-
case letters on the input lines. A letter escaped with `\'
in the pattern must be matched in exactly that case.
***** See Also *****
awk, commands, ed, expr, grep, lex, sed
***** Diagnostics *****
egrep returns an exit status of zero for success, one for no
matches, and two for error.
***** Notes *****
Besides the difference in the range of patterns allowed, egrep
uses a deterministic finite automaton (DFA) for the search. It
builds the DFA dynamically, so it begins doing useful work im-
mediately. This means that egrep is is much faster than grep,
often by more than an order of magnitude, and is considerably
COHERENT Lexicon Page 2
egrep Command egrep
faster than earlier pattern-searching commands, on almost any
length of file.
COHERENT Lexicon Page 3
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.