View | Details | Raw Unified | Return to bug 219578
Collapse All | Expand All

(-)b/usr.bin/grep/grep.1 (-29 / +29 lines)
Lines 30-36 Link Here
30
.\"
30
.\"
31
.\"	@(#)grep.1	8.3 (Berkeley) 4/18/94
31
.\"	@(#)grep.1	8.3 (Berkeley) 4/18/94
32
.\"
32
.\"
33
.Dd April 17, 2017
33
.Dd May 26, 2017
34
.Dt GREP 1
34
.Dt GREP 1
35
.Os
35
.Os
36
.Sh NAME
36
.Sh NAME
Lines 40-46 Link Here
40
.Sh SYNOPSIS
40
.Sh SYNOPSIS
41
.Nm grep
41
.Nm grep
42
.Bk -words
42
.Bk -words
43
.Op Fl abcdDEFGHhIiJLlmnOopqRSsUVvwxZz
43
.Op Fl abcDdEFGHhIiJLlmnOopqRSsUVvwxZz
44
.Op Fl A Ar num
44
.Op Fl A Ar num
45
.Op Fl B Ar num
45
.Op Fl B Ar num
46
.Op Fl C Ns Op Ar num
46
.Op Fl C Ns Op Ar num
Lines 48-57 Link Here
48
.Op Fl f Ar file
48
.Op Fl f Ar file
49
.Op Fl Fl binary-files Ns = Ns Ar value
49
.Op Fl Fl binary-files Ns = Ns Ar value
50
.Op Fl Fl color Ns Op = Ns Ar when
50
.Op Fl Fl color Ns Op = Ns Ar when
51
.Op Fl Fl colour Ns Op = Ns Ar when
51
.Op Fl Fl exclude Ns = Ns Ar pattern
52
.Op Fl Fl context Ns Op = Ns Ar num
52
.Op Fl Fl exclude-dir Ns = Ns Ar pattern
53
.Op Fl Fl label
53
.Op Fl Fl include Ns = Ns Ar pattern
54
.Op Fl Fl include-dir Ns = Ns Ar pattern
55
.Op Fl Fl label Ns = Ns Ar value
54
.Op Fl Fl line-buffered
56
.Op Fl Fl line-buffered
57
.Op Fl Fl mmap
55
.Op Fl Fl null
58
.Op Fl Fl null
56
.Op Ar pattern
59
.Op Ar pattern
57
.Op Ar
60
.Op Ar
Lines 136-142 options. Link Here
136
.It Fl b , Fl Fl byte-offset
139
.It Fl b , Fl Fl byte-offset
137
The offset in bytes of a matched pattern is
140
The offset in bytes of a matched pattern is
138
displayed in front of the respective matched line.
141
displayed in front of the respective matched line.
139
.It Fl C Ns Op Ar num , Fl Fl context Ns = Ns Ar num
142
.It Fl Fl binary-files Ns = Ns Ar value
143
Controls searching and printing of binary files.
144
Options are
145
.Ar binary ,
146
the default: search binary files but do not print them;
147
.Ar without-match :
148
do not search binary files;
149
and
150
.Ar text :
151
treat all files as text.
152
.It Fl C Ns Oo Ar num Oc , Fl Fl context Ns Oo = Ns Ar num Oc
140
Print
153
Print
141
.Ar num
154
.Ar num
142
lines of leading and trailing context surrounding each match.
155
lines of leading and trailing context surrounding each match.
Lines 149-155 Note: Link Here
149
no whitespace may be given between the option and its argument.
162
no whitespace may be given between the option and its argument.
150
.It Fl c , Fl Fl count
163
.It Fl c , Fl Fl count
151
Only a count of selected lines is written to standard output.
164
Only a count of selected lines is written to standard output.
152
.It Fl Fl colour Ns = Ns Op Ar when , Fl Fl color Ns = Ns Op Ar when
165
.It Fl Fl color Ns Oo = Ns Ar when Oc , Fl Fl colour Ns Oo = Ns Ar when Oc
153
Mark up the matching text with the expression stored in
166
Mark up the matching text with the expression stored in
154
.Ev GREP_COLOR
167
.Ev GREP_COLOR
155
environment variable.
168
environment variable.
Lines 295-300 Pathnames are listed once per file searched. Link Here
295
If the standard input is searched, the string
308
If the standard input is searched, the string
296
.Dq (standard input)
309
.Dq (standard input)
297
is written.
310
is written.
311
.It Fl Fl label Ns = Ns Ar value
312
When reading from standard input, display
313
.Ar value
314
as file name.
315
.It Fl Fl line-buffered
316
Force output to be line buffered.
317
By default, output is line buffered when standard output is a terminal
318
and block buffered otherwise.
298
.It Fl Fl mmap
319
.It Fl Fl mmap
299
Use
320
Use
300
.Xr mmap 2
321
.Xr mmap 2
Lines 386-412 Force Link Here
386
.Nm grep
407
.Nm grep
387
to behave as
408
to behave as
388
.Nm zgrep .
409
.Nm zgrep .
389
.It Fl Fl binary-files Ns = Ns Ar value
390
Controls searching and printing of binary files.
391
Options are
392
.Ar binary ,
393
the default: search binary files but do not print them;
394
.Ar without-match :
395
do not search binary files;
396
and
397
.Ar text :
398
treat all files as text.
399
.Sm off
400
.It Fl Fl context Op = Ar num
401
.Sm on
402
Print
403
.Ar num
404
lines of leading and trailing context.
405
The default is 2.
406
.It Fl Fl line-buffered
407
Force output to be line buffered.
408
By default, output is line buffered when standard output is a terminal
409
and block buffered otherwise.
410
.El
410
.El
411
.Pp
411
.Pp
412
If no file arguments are specified, the standard input is used.
412
If no file arguments are specified, the standard input is used.
Lines 476-482 utility is compliant with the Link Here
476
specification.
476
specification.
477
.Pp
477
.Pp
478
The flags
478
The flags
479
.Op Fl AaBbCDdGHhIJLmoPRSUVwZ
479
.Op Fl AaBbCDdGHhIJLmopRSUVwZ
480
are extensions to that specification, and the behaviour of the
480
are extensions to that specification, and the behaviour of the
481
.Fl f
481
.Fl f
482
flag when used with an empty pattern file is left undefined.
482
flag when used with an empty pattern file is left undefined.
(-)b/usr.bin/grep/grep.c (-5 / +7 lines)
Lines 68-76 const char *errstr[] = { Link Here
68
/* 1*/	"(standard input)",
68
/* 1*/	"(standard input)",
69
/* 2*/	"cannot read bzip2 compressed file",
69
/* 2*/	"cannot read bzip2 compressed file",
70
/* 3*/	"unknown %s option",
70
/* 3*/	"unknown %s option",
71
/* 4*/	"usage: %s [-abcDEFGHhIiJLlmnOoPqRSsUVvwxZz] [-A num] [-B num] [-C[num]]\n",
71
/* 4*/	"usage: %s [-abcDEFGHhIiJLlmnOopqRSsUVvwxZz] [-A num] [-B num] [-C[num]]\n",
72
/* 5*/	"\t[-e pattern] [-f file] [--binary-files=value] [--color=when]\n",
72
/* 5*/	"\t[-e pattern] [-f file] [--binary-files=value] [--color[=when]]\n"
73
/* 6*/	"\t[--context[=num]] [--directories=action] [--label] [--line-buffered]\n",
73
	"\t[--exclude=pattern] [--exclude-dir=pattern] [--include=pattern]\n",
74
/* 6*/	"\t[--include-dir=pattern] [--label=value] [--line-buffered] [--mmap]\n",
74
/* 7*/	"\t[--null] [pattern] [file ...]\n",
75
/* 7*/	"\t[--null] [pattern] [file ...]\n",
75
/* 8*/	"Binary file %s matches\n",
76
/* 8*/	"Binary file %s matches\n",
76
/* 9*/	"%s (BSD grep) %s\n",
77
/* 9*/	"%s (BSD grep) %s\n",
Lines 174-180 usage(void) Link Here
174
	exit(2);
175
	exit(2);
175
}
176
}
176
177
177
static const char	*optstr = "0123456789A:B:C:D:EFGHIJMLOPSRUVZabcd:e:f:hilm:nopqrsuvwxXyz";
178
static const char	*optstr =
179
	"0123456789A:B:C:D:EFGHIJMLOSRUVZabcd:e:f:hilm:nopqrsuvwxXyz";
178
180
179
static const struct option long_options[] =
181
static const struct option long_options[] =
180
{
182
{
Lines 197-203 static const struct option long_options[] = Link Here
197
	{"context",		optional_argument,	NULL, 'C'},
199
	{"context",		optional_argument,	NULL, 'C'},
198
	{"count",		no_argument,		NULL, 'c'},
200
	{"count",		no_argument,		NULL, 'c'},
199
	{"devices",		required_argument,	NULL, 'D'},
201
	{"devices",		required_argument,	NULL, 'D'},
200
        {"directories",		required_argument,	NULL, 'd'},
202
	{"directories",		required_argument,	NULL, 'd'},
201
	{"extended-regexp",	no_argument,		NULL, 'E'},
203
	{"extended-regexp",	no_argument,		NULL, 'E'},
202
	{"regexp",		required_argument,	NULL, 'e'},
204
	{"regexp",		required_argument,	NULL, 'e'},
203
	{"fixed-strings",	no_argument,		NULL, 'F'},
205
	{"fixed-strings",	no_argument,		NULL, 'F'},

Return to bug 219578