Update grep(1) manpage and usage line
This commit is contained in:
parent
64e7504314
commit
8d26936b83
124
grep.1
124
grep.1
|
@ -1,80 +1,86 @@
|
||||||
.TH GREP 1 sbase\-VERSION
|
.Dd November 21, 2014
|
||||||
.SH NAME
|
.Dt GREP 1 sbase\-VERSION
|
||||||
grep \- search files for a pattern
|
.Sh NAME
|
||||||
.SH SYNOPSIS
|
.Nm grep
|
||||||
.B grep
|
.Nd search files for patterns
|
||||||
.RB [ \-EFHchilnqsvx ]
|
.Sh SYNOPSIS
|
||||||
.RB [ \-e
|
.Nm grep
|
||||||
.I pattern ]
|
.Op Fl EFHchilnqsvx
|
||||||
.RB [ \-f
|
.Op Fl e Ar pattern
|
||||||
.I file ]
|
.Op Fl f Ar file
|
||||||
.I pattern
|
.Op Ar pattern
|
||||||
.RI [ file ...]
|
.Op Ar file ...
|
||||||
.SH DESCRIPTION
|
.Sh DESCRIPTION
|
||||||
.B grep
|
.Nm
|
||||||
searches the input files for lines that match the
|
searches the input files for lines that match the
|
||||||
.IR pattern ,
|
.Ar pattern ,
|
||||||
a regular expression as defined in
|
a regular expression as defined in
|
||||||
.IR regex (7).
|
.Xr regex 7 .
|
||||||
By default each matching line is printed to stdout. If no file is given, grep
|
By default each matching line is printed to stdout. If no file is given
|
||||||
|
.Nm
|
||||||
reads from stdin.
|
reads from stdin.
|
||||||
.P
|
.Sh OPTIONS
|
||||||
The status code is 0 if any lines match, and 1 if not. If an error occurred the
|
.Bl -tag -width Ds
|
||||||
status code is 2.
|
.It Fl E
|
||||||
.SH OPTIONS
|
Match using extended regex.
|
||||||
.TP
|
.It Fl F
|
||||||
.B \-E
|
|
||||||
Matches using extended regex.
|
|
||||||
.TP
|
|
||||||
.B \-F
|
|
||||||
Match using fixed strings. Treat each pattern specified as a string instead of a regular
|
Match using fixed strings. Treat each pattern specified as a string instead of a regular
|
||||||
expression.
|
expression.
|
||||||
.TP
|
.It Fl H
|
||||||
.B \-H
|
Prefix each matching line with its filename in the output. This is the
|
||||||
Prefixes each matching line with its filename in the output. This is the
|
|
||||||
default when there is more than one file specified.
|
default when there is more than one file specified.
|
||||||
.TP
|
.It Fl c
|
||||||
.B \-c
|
Print only a count of matching lines.
|
||||||
Prints only a count of matching lines.
|
.It Fl e Ar pattern
|
||||||
.TP
|
|
||||||
.B \-e pattern
|
|
||||||
Specify a pattern used during the search of the input: an input
|
Specify a pattern used during the search of the input: an input
|
||||||
line is selected if it matches any of the specified patterns.
|
line is selected if it matches any of the specified patterns.
|
||||||
This option is most useful when multiple -e options are used to
|
This option is most useful when multiple -e options are used to
|
||||||
specify multiple patterns, or when a pattern begins with a dash
|
specify multiple patterns, or when a pattern begins with a dash
|
||||||
.TP
|
.It Fl f Ar file
|
||||||
.B \-f file
|
|
||||||
Read one or more patterns from the file named by the pathname file.
|
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
|
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
|
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.
|
also specified, each pattern shall be treated as a BRE.
|
||||||
(`-').
|
(`-').
|
||||||
.TP
|
.It Fl h
|
||||||
.B \-h
|
|
||||||
Do not prefix each line with 'filename:' prefix.
|
Do not prefix each line with 'filename:' prefix.
|
||||||
.TP
|
.It Fl i
|
||||||
.B \-i
|
Match lines case insensitively.
|
||||||
Matches lines case insensitively.
|
.It Fl l
|
||||||
.TP
|
Print only the names of files with matching lines.
|
||||||
.B \-l
|
.It Fl n
|
||||||
Prints only the names of files with matching lines.
|
Prefix each matching line with its line number in the input.
|
||||||
.TP
|
.It Fl q
|
||||||
.B \-n
|
Print nothing, only returns status.
|
||||||
Prefixes each matching line with its line number in the input.
|
.It Fl s
|
||||||
.TP
|
|
||||||
.B \-q
|
|
||||||
Prints nothing, only returns status.
|
|
||||||
.TP
|
|
||||||
.B \-s
|
|
||||||
Suppress the error messages ordinarily written for nonexistent or unreadable files.
|
Suppress the error messages ordinarily written for nonexistent or unreadable files.
|
||||||
.TP
|
.It Fl v
|
||||||
.B \-v
|
Select lines which do
|
||||||
Selects lines which do
|
|
||||||
.B not
|
.B not
|
||||||
Match the pattern.
|
Match the pattern.
|
||||||
.TP
|
.It Fl x
|
||||||
.B \-x
|
|
||||||
Consider only input lines that use all characters in the line excluding the terminating <newline> to
|
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.
|
match an entire fixed string or regular expression to be matching lines.
|
||||||
.SH SEE ALSO
|
.El
|
||||||
.IR regex (7)
|
.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
|
||||||
|
.Xr regex 7 ,
|
||||||
|
.Xr sed 1
|
||||||
|
.Sh STANDARDS
|
||||||
|
The
|
||||||
|
.Nm
|
||||||
|
utility is compliant with the
|
||||||
|
.St -p1003.1-2008
|
||||||
|
specification.
|
||||||
|
.Pp
|
||||||
|
The flags
|
||||||
|
.Op Fl Hh
|
||||||
|
are an extension to that specification.
|
||||||
|
|
2
grep.c
2
grep.c
|
@ -39,7 +39,7 @@ static SLIST_HEAD(phead, pattern) phead;
|
||||||
static void
|
static void
|
||||||
usage(void)
|
usage(void)
|
||||||
{
|
{
|
||||||
enprintf(Error, "usage: %s [-EFHcilnqsvx] [-e pattern] [-f file] pattern [files...]\n", argv0);
|
enprintf(Error, "usage: %s [-EFHcilnqsvx] [-e pattern] [-f file] [pattern] [file ...]\n", argv0);
|
||||||
}
|
}
|
||||||
|
|
||||||
int
|
int
|
||||||
|
|
Loading…
Reference in New Issue
Block a user