Plan 9 from Bell Labs’s /usr/web/sources/patch/grepcapi/grep.orig
Copyright © 2021 Plan 9 Foundation.
Distributed under the
Download the Plan 9 distribution.
.TH GREP 1
grep \- search a file for a pattern
.I file ...
searches the input
(standard input default)
for lines that match the
.IR pattern ,
a regular expression as defined in
.IR regexp (6)
with the addition of a newline character as an alternative
.BR | )
with lowest precedence.
Normally, each line matching the pattern is `selected',
and each selected line is copied to the standard output.
The options are
Print only a count of matching lines.
Do not print file name tags (headers) with output lines.
The following argument is taken as a
.IR pattern .
This option makes it easy to specify patterns that
might confuse argument parsing, such as
.BR -n .
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.
(ell) Print the names of files with selected lines; don't print the lines.
Print the names of files with no selected lines;
the converse of
.BR -l .
Mark each printed line with its line number counted in its file.
Produce no output, but return status.
Reverse: print lines that do not match the pattern.
The pattern argument is the name of a file containing regular
expressions one per line.
Don't buffer the output: write each output line as soon as it is discovered.
Output lines are tagged by file name when there is more than one
(To force this tagging, include
as a file name argument.)
Care should be taken when
using the shell metacharacters
.IR pattern ;
it is safest to enclose the
in single quotes
.BR \&\|' \|.\|.\|.\| ' .
An expression starting with '*'
will treat the rest of the expression
as literal characters.
.SH SEE ALSO
.IR ed (1),
.IR awk (1),
.IR sed (1),
.IR sam (1),
.IR regexp (6)
Exit status is null if any lines are selected,
or non-null when no lines are selected or an error occurs.
(Return to Plan 9 Home Page)
© 2021 Plan 9 Foundation.
All Rights Reserved.