2014-11-21 13:10:29 +00:00
|
|
|
.Dd November 21, 2014
|
2015-01-31 13:20:02 +00:00
|
|
|
.Dt GREP 1
|
2015-01-31 19:37:03 +00:00
|
|
|
.Os sbase
|
2014-11-21 13:10:29 +00:00
|
|
|
.Sh NAME
|
|
|
|
.Nm grep
|
|
|
|
.Nd search files for patterns
|
|
|
|
.Sh SYNOPSIS
|
2015-01-30 20:17:58 +00:00
|
|
|
.Nm
|
2014-11-21 13:10:29 +00:00
|
|
|
.Op Fl EFHchilnqsvx
|
|
|
|
.Op Fl e Ar pattern
|
|
|
|
.Op Fl f Ar file
|
|
|
|
.Op Ar pattern
|
|
|
|
.Op Ar file ...
|
|
|
|
.Sh DESCRIPTION
|
|
|
|
.Nm
|
2011-06-18 05:42:24 +00:00
|
|
|
searches the input files for lines that match the
|
2014-11-21 13:10:29 +00:00
|
|
|
.Ar pattern ,
|
2011-06-18 05:42:24 +00:00
|
|
|
a regular expression as defined in
|
2014-11-21 13:10:29 +00:00
|
|
|
.Xr regex 7 .
|
2015-02-01 19:52:28 +00:00
|
|
|
By default each matching line is printed to stdout. If no
|
|
|
|
.Ar file
|
|
|
|
is given
|
2014-11-21 13:10:29 +00:00
|
|
|
.Nm
|
2011-05-23 01:36:34 +00:00
|
|
|
reads from stdin.
|
2014-11-21 13:10:29 +00:00
|
|
|
.Sh OPTIONS
|
|
|
|
.Bl -tag -width Ds
|
|
|
|
.It Fl E
|
|
|
|
Match using extended regex.
|
|
|
|
.It Fl F
|
2015-01-31 13:43:27 +00:00
|
|
|
Match using fixed strings. Treat each pattern specified as a string instead of
|
|
|
|
a regular expression.
|
2014-11-21 13:10:29 +00:00
|
|
|
.It Fl H
|
|
|
|
Prefix each matching line with its filename in the output. This is the
|
2014-11-16 10:45:10 +00:00
|
|
|
default when there is more than one file specified.
|
2014-11-21 13:10:29 +00:00
|
|
|
.It Fl c
|
|
|
|
Print only a count of matching lines.
|
|
|
|
.It Fl e Ar pattern
|
2013-09-27 15:26:22 +00:00
|
|
|
Specify a pattern used during the search of the input: an input
|
|
|
|
line is selected if it matches any of the specified patterns.
|
|
|
|
This option is most useful when multiple -e options are used to
|
2015-02-01 19:52:28 +00:00
|
|
|
specify multiple patterns, or when a pattern begins with a dash.
|
2014-11-21 13:10:29 +00:00
|
|
|
.It Fl f Ar file
|
2014-11-20 16:57:49 +00:00
|
|
|
Read one or more patterns from the file named by the pathname file.
|
|
|
|
Patterns in file shall be terminated by a <newline>. A null pattern can be
|
|
|
|
specified by an empty line in pattern_file. Unless the -E or -F option is
|
|
|
|
also specified, each pattern shall be treated as a BRE.
|
2013-09-27 15:26:22 +00:00
|
|
|
(`-').
|
2014-11-21 13:10:29 +00:00
|
|
|
.It Fl h
|
2014-11-20 14:35:23 +00:00
|
|
|
Do not prefix each line with 'filename:' prefix.
|
2014-11-21 13:10:29 +00:00
|
|
|
.It Fl i
|
|
|
|
Match lines case insensitively.
|
|
|
|
.It Fl l
|
|
|
|
Print only the names of files with matching lines.
|
|
|
|
.It Fl n
|
|
|
|
Prefix each matching line with its line number in the input.
|
|
|
|
.It Fl q
|
2014-11-21 14:22:22 +00:00
|
|
|
Print nothing, only return status.
|
2014-11-21 13:10:29 +00:00
|
|
|
.It Fl s
|
2015-01-31 13:43:27 +00:00
|
|
|
Suppress the error messages ordinarily written for nonexistent or unreadable
|
|
|
|
files.
|
2014-11-21 13:10:29 +00:00
|
|
|
.It Fl v
|
|
|
|
Select lines which do
|
2015-01-30 20:17:58 +00:00
|
|
|
.Sy not
|
|
|
|
match the pattern.
|
2015-01-22 17:07:57 +00:00
|
|
|
.It Fl w
|
2015-01-22 17:50:07 +00:00
|
|
|
The expression is searched for as a word (as if surrounded by '\<' and '\>').
|
2014-11-21 13:10:29 +00:00
|
|
|
.It Fl x
|
2015-01-31 13:43:27 +00:00
|
|
|
Consider only input lines that use all characters in the line excluding the
|
|
|
|
terminating <newline> to match an entire fixed string or regular expression to
|
|
|
|
be matching lines.
|
2014-11-21 13:10:29 +00:00
|
|
|
.El
|
|
|
|
.Sh EXIT STATUS
|
|
|
|
.Bl -tag -width Ds
|
|
|
|
.It 0
|
|
|
|
One or more lines were matched.
|
|
|
|
.It 1
|
|
|
|
No lines were matched.
|
|
|
|
.It > 1
|
|
|
|
An error occurred.
|
|
|
|
.El
|
|
|
|
.Sh SEE ALSO
|
2015-01-31 13:43:27 +00:00
|
|
|
.Xr sed 1 ,
|
|
|
|
.Xr regex 7
|
2014-11-21 13:10:29 +00:00
|
|
|
.Sh STANDARDS
|
|
|
|
The
|
|
|
|
.Nm
|
|
|
|
utility is compliant with the
|
|
|
|
.St -p1003.1-2008
|
|
|
|
specification.
|
|
|
|
.Pp
|
|
|
|
The flags
|
2015-01-22 17:07:57 +00:00
|
|
|
.Op Fl Hhw
|
2014-11-21 13:10:29 +00:00
|
|
|
are an extension to that specification.
|