'\"macro stdmacro
.if n .pH g1.egrep @(#)egrep	40.5 of 10/10/89
.\" Copyright 1989 AT&T
.nr X
.if \nX=0 .ds x} egrep 1 "Directory and File Management Utilities" "\&"
.if \nX=1 .ds x} egrep 1 "Directory and File Management Utilities"
.if \nX=2 .ds x} egrep 1 "" "\&"
.if \nX=3 .ds x} egrep "" "" "\&"
.TH \*(x}
.SH NAME
\f4egrep\f1 \- search a file for a pattern using full regular expressions
.SH SYNOPSIS
\f4egrep\f1
[\f2options\f1] \f4full regular expression\fP [\f2file\f1 ...]
.SH DESCRIPTION
\f4egrep\fP
(\f2expression grep\f1) searches files for a pattern of characters and
prints all lines that contain that pattern.
\f4egrep\fP
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.
.PP
\f4egrep\fP
accepts full regular expressions as in
\f4ed\fP(1),
except for
\f4\e(\f1
and
\f4\e)\f1,
with the addition of:
.PP
.PD 0
.TP 6
1.
A full regular expression followed by
\f4+\f1
that matches one or more occurrences of the full regular
expression.
.TP
2.
A full regular expression followed by
\f4?\f1
that matches 0 or 1 occurrences of the full regular expression.
.TP
3.
Full regular expressions separated by \(bv or
by a new-line that match strings that are matched by any of the expressions.
.TP
4.
A full regular expression that may be enclosed in parentheses
\f4(\|)\f1
for grouping.
.PD
.PP
Be careful using the characters
\f4$\f1,
\f4*\f1,
\f4[\f1,
\f4^\f1,
\(bv,
\f4(\f1,
\f4)\f1,
and
\f4\e\f1
in
\f2full regular expression\f1, because they are
also meaningful to the shell.
It is safest to enclose the entire
.I full regular expression\^
in single quotes
\f4\&\|\(fm\f1\|.\|.\|.\|\f4\(fm\f1.
.PP
The order of precedence of operators is
\f4[\|]\f1,
then
\f4\(**\|?\|+\f1,
then concatenation, then \(bv and new-line.
.PP
If no files are specified,
\f4egrep\fP
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.
.PP
Command line options are:
.PP
.PD 0
.TP 6
\f4\-b\f1
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).
.TP
\f4\-c\f1
Print only a count of the lines that contain the pattern.
.TP
\f4\-i\f1
Ignore upper/lower case distinction during comparisons.
.TP
\f4\-h\f1
Suppress printing of filenames when searching multiple files.
.TP
\f4\-l\f1
Print the names of files with matching lines once,
separated by new-lines.
Does not repeat the names of files when the pattern is found
more than once.
.TP
\f4\-n\f1
Precede each line by its line number in the file (first line is 1).
.TP
\f4\-v\f1
Print all lines except those that contain the pattern.
.TP
\f4\-e\f2 special_expression\^\f1
Search for a
.I "special expression\^"
.RI ( "full regular expression\^"
that begins with a
\f4\-\f1).
.TP
\f4\-f\f2 file\^\f1
Take the list of
.I full regular expressions\^
from 
.IR file .
.PD
.SH SEE ALSO
\f4ed\fP(1),
\f4fgrep\fP(1),
\f4grep\fP(1),
\f4sed\fP(1),
\f4sh\fP(1).
.SH DIAGNOSTICS
Exit status is 0 if any matches are found,
1 if none, 2 for syntax errors or inaccessible files
(even if matches were found).
.SH NOTES
Ideally there should be only one
\f4grep\fP
command, but there is not a single algorithm that spans a wide enough
range of space-time tradeoffs.  Lines are limited to BUFSIZ characters;
longer lines are truncated.  BUFSIZ is defined in 
\f4/usr/include/stdio.h.\f1
.Ee
