2BSD/man/grep.u

.TH GREP UCB 2/24/79 UCB
.SH NAME
grep \- search a file for a pattern
.SH SYNOPSIS
.B grep
[
.B \-v
] [
.B \-b
] [
.B \-c
] [
.B \-n
] [
.B \-l
] [
.B \-i
] [
.B \-w
] expression [ file ] ...
.SH DESCRIPTION
.I Grep
searches the input files
(standard input default)
for lines matching the
regular expression.
Normally, each line found
is copied to the standard output.
If the
.B \-v
flag is used,
all lines but those matching
are printed.
If the
.B \-c
flag is used,
only a count of matching lines is printed.
If the
.B \-l
flag is used,
only names of files which contain matching lines are printed.
If the
.B \-i
flag is used, then case of letters is ignored in comparisons.
If the
.B \-w
flag is used, then the expression is searched for as a word
(as if surrounded by `\e<' and `\e>',
see
.IR ex (UCB))
If the
.B \-n
flag is used,
each line is preceded
its relative line number in the file.
If the
.B \-b
flag is used,
each line is preceded by the block number
on which it was found.
This is sometimes useful in locating
disk block numbers by context.
.PP
In all cases the file name is shown if there is more than one input file.
.PP
For a complete description
of the regular expressions,
see
.IR ex (UCB).
Care should be taken when
using the characters
$ * [ ^ | ( ) and \\ in the regular
expression as they are
also meaningful to the Shell.
It is generally necessary to enclose the
entire
.I expression
argument in quotes.
.SH "SEE ALSO"
ex(UCB)
.SH BUGS
Lines
are limited to 256 characters;
longer lines are truncated.