32 |
.RI [ FILE .\|.\|.] |
.RI [ FILE .\|.\|.] |
33 |
.SH DESCRIPTION |
.SH DESCRIPTION |
34 |
.PP |
.PP |
35 |
.B Grep |
The |
36 |
searches the named input |
.B grep |
37 |
|
command searches the named input |
38 |
.IR FILE s |
.IR FILE s |
39 |
(or standard input if no files are named, or |
(or standard input if no files are named, or |
40 |
the file name |
the file name |
51 |
and |
and |
52 |
.B fgrep |
.B fgrep |
53 |
are available. |
are available. |
54 |
.B Egrep |
.B egrep |
55 |
is the same as |
is the same as |
56 |
.BR "grep\ \-E" . |
.BR "grep\ \-E" . |
57 |
.B Fgrep |
.B fgrep |
58 |
is the same as |
is the same as |
59 |
.BR "grep\ \-F" . |
.BR "grep\ \-F" . |
60 |
|
Direct invocation as either |
61 |
|
.B egrep |
62 |
|
or |
63 |
|
.B fgrep |
64 |
|
is deprecated, |
65 |
|
but is provided to allow historical applications |
66 |
|
that rely on them to run unmodified. |
67 |
.SH OPTIONS |
.SH OPTIONS |
68 |
.TP |
.TP |
69 |
.BI \-A " NUM" "\fR,\fP \-\^\-after-context=" NUM |
.BI \-A " NUM" "\fR,\fP \-\^\-after-context=" NUM |
263 |
.BI \-\^\-label= LABEL |
.BI \-\^\-label= LABEL |
264 |
Display input actually coming from standard input as input coming from file |
Display input actually coming from standard input as input coming from file |
265 |
.I LABEL. |
.I LABEL. |
266 |
This is especially useful for tools like zgrep, e.g. |
This is especially useful for tools like |
267 |
.B "gzip -cd foo.gz |grep --label=foo something" |
.BR zgrep , |
268 |
|
e.g., |
269 |
|
.B "gzip -cd foo.gz | grep --label=foo something" |
270 |
.TP |
.TP |
271 |
.BR \-\^\-line-buffered |
.BR \-\^\-line-buffered |
272 |
Use line buffering, it can be a performance penalty. |
Use line buffering, it can be a performance penalty. |
416 |
.BR \-u ", " \-\^\-unix-byte-offsets |
.BR \-u ", " \-\^\-unix-byte-offsets |
417 |
Report Unix-style byte offsets. This switch causes |
Report Unix-style byte offsets. This switch causes |
418 |
.B grep |
.B grep |
419 |
to report byte offsets as if the file were Unix-style text file, i.e. with |
to report byte offsets as if the file were Unix-style text file, i.e., with |
420 |
CR characters stripped off. This will produce results identical to running |
CR characters stripped off. This will produce results identical to running |
421 |
.B grep |
.B grep |
422 |
on a Unix machine. This option has no effect unless |
on a Unix machine. This option has no effect unless |
471 |
Regular expressions are constructed analogously to arithmetic |
Regular expressions are constructed analogously to arithmetic |
472 |
expressions, by using various operators to combine smaller expressions. |
expressions, by using various operators to combine smaller expressions. |
473 |
.PP |
.PP |
474 |
.B Grep |
The |
475 |
understands two different versions of regular expression syntax: |
.B grep |
476 |
|
command understands two different versions of regular expression syntax: |
477 |
\*(lqbasic\*(rq and \*(lqextended.\*(rq In |
\*(lqbasic\*(rq and \*(lqextended.\*(rq In |
478 |
.RB "\s-1GNU\s0\ " grep , |
.RB "\s-1GNU\s0\ " grep , |
479 |
there is no difference in available functionality using either syntax. |
there is no difference in available functionality using either syntax. |
672 |
instead, so portable scripts should avoid |
instead, so portable scripts should avoid |
673 |
.B { |
.B { |
674 |
in |
in |
675 |
.B egrep |
.B "grep\ \-E" |
676 |
patterns and should use |
patterns and should use |
677 |
.B [{] |
.B [{] |
678 |
to match a literal |
to match a literal |
679 |
.BR { . |
.BR { . |
680 |
.PP |
.PP |
681 |
\s-1GNU\s0 |
\s-1GNU\s0 |
682 |
.B egrep |
.B "grep\ \-E" |
683 |
attempts to support traditional usage by assuming that |
attempts to support traditional usage by assuming that |
684 |
.B { |
.B { |
685 |
is not special if it would be the start of an invalid interval |
is not special if it would be the start of an invalid interval |
686 |
specification. For example, the shell command |
specification. For example, the shell command |
687 |
.B "egrep '{1'" |
.B "grep\ \-E\ '{1'" |
688 |
searches for the two-character string |
searches for the two-character string |
689 |
.B {1 |
.B {1 |
690 |
instead of reporting a syntax error in the regular expression. |
instead of reporting a syntax error in the regular expression. |
691 |
\s-1POSIX.2\s0 allows this behavior as an extension, but portable scripts |
\s-1POSIX.2\s0 allows this behavior as an extension, but portable scripts |
692 |
should avoid it. |
should avoid it. |
693 |
.SH "ENVIRONMENT VARIABLES" |
.SH "ENVIRONMENT VARIABLES" |
694 |
Grep's behavior is affected by the following environment variables. |
The behavior of |
695 |
|
.B grep |
696 |
|
is affected by the following environment variables. |
697 |
.PP |
.PP |
698 |
A locale |
A locale |
699 |
.BI LC_ foo |
.BI LC_ foo |