.TH GREP 1
.SH NAME
grep \- search a file for a pattern
.SH SYNOPSIS
.B grep
[
.I option ...
]
.I pattern
[
.I file ...
]
.SH DESCRIPTION
.I Grep\^
searches the input
.I files\^
(standard input default)
for lines (with newlines excluded) that match the
.I pattern,
a regular expression as defined in
.IR regexp (6).
Normally, each line matching the pattern is `selected',
and each selected line is copied to the standard output.
The options are
.TP
.B -c
Print only a count of matching lines.
.PD 0
.TP
.B -h
Do not print file name tags (headers) with output lines.
.TP
.B -i
Ignore alphabetic case distinctions.  The implementation
folds into lower case all letters in the pattern and input before
interpretation.  Matched lines are printed in their original form.
.TP
.B -l
(ell) Print the names of files with selected lines; don't print the lines.
.TP
.B -L
Print the names of files with no selected lines;
the converse of
.BR -l .
.TP
.B -n
Mark each printed line with its line number counted in its file.
.TP
.B -s
Produce no output, but return status.
.TP
.B -v
Reverse: print lines that do not match the pattern.
.PD
.PP
Output lines are tagged by file name when there is more than one
input file.
(To force this tagging, include
.B /dev/null
as a file name argument.)
.PP
Care should be taken when
using the shell metacharacters
.B $*[^|()=\e
and newline
in
.IR pattern ;
it is safest to enclose the
entire expression
in single quotes
.BR \&\|\(fm \|.\|.\|.\| \(fm .
.SH SEE ALSO
.IR ed (1),
.IR awk (1),
.IR sed (1),
.IR sam (1),
.IR regexp (6)
.SH DIAGNOSTICS
Exit status is null if any lines are selected,
or non-null when none are selected or an error occurs.
