| 39 |
.sp |
.sp |
| 40 |
pcregrep some-pattern /file1 - /file3 |
pcregrep some-pattern /file1 - /file3 |
| 41 |
.sp |
.sp |
| 42 |
By default, each line that matches the pattern is copied to the standard |
By default, each line that matches a pattern is copied to the standard |
| 43 |
output, and if there is more than one file, the file name is output at the |
output, and if there is more than one file, the file name is output at the |
| 44 |
start of each line, followed by a colon. However, there are options that can |
start of each line, followed by a colon. However, there are options that can |
| 45 |
change how \fBpcregrep\fP behaves. In particular, the \fB-M\fP option makes it |
change how \fBpcregrep\fP behaves. In particular, the \fB-M\fP option makes it |
| 47 |
boundary is controlled by the \fB-N\fP (\fB--newline\fP) option. |
boundary is controlled by the \fB-N\fP (\fB--newline\fP) option. |
| 48 |
.P |
.P |
| 49 |
Patterns are limited to 8K or BUFSIZ characters, whichever is the greater. |
Patterns are limited to 8K or BUFSIZ characters, whichever is the greater. |
| 50 |
BUFSIZ is defined in \fB<stdio.h>\fP. |
BUFSIZ is defined in \fB<stdio.h>\fP. When there is more than one pattern |
| 51 |
|
(specified by the use of \fB-e\fP and/or \fB-f\fP), each pattern is applied to |
| 52 |
|
each line in the order in which they are defined, except that all the \fB-e\fP |
| 53 |
|
patterns are tried before the \fB-f\fP patterns. As soon as one pattern matches |
| 54 |
|
(or fails to match when \fB-v\fP is used), no further patterns are considered. |
| 55 |
|
.P |
| 56 |
|
When \fB--only-matching\fP, \fB--file-offsets\fP, or \fB--line-offsets\fP |
| 57 |
|
is used, the output is the part of the line that matched (either shown |
| 58 |
|
literally, or as an offset). In this case, scanning resumes immediately |
| 59 |
|
following the match, so that further matches on the same line can be found. |
| 60 |
|
If there are multiple patterns, they are all tried on the remainder of the |
| 61 |
|
line. However, patterns that follow the one that matched are not tried on the |
| 62 |
|
earlier part of the line. |
| 63 |
.P |
.P |
| 64 |
If the \fBLC_ALL\fP or \fBLC_CTYPE\fP environment variable is set, |
If the \fBLC_ALL\fP or \fBLC_CTYPE\fP environment variable is set, |
| 65 |
\fBpcregrep\fP uses the value to set a locale when calling the PCRE library. |
\fBpcregrep\fP uses the value to set a locale when calling the PCRE library. |
| 168 |
is taken from the command line; all arguments are treated as file names. There |
is taken from the command line; all arguments are treated as file names. There |
| 169 |
is an overall maximum of 100 patterns. Trailing white space is removed from |
is an overall maximum of 100 patterns. Trailing white space is removed from |
| 170 |
each line, and blank lines are ignored. An empty file contains no patterns and |
each line, and blank lines are ignored. An empty file contains no patterns and |
| 171 |
therefore matches nothing. |
therefore matches nothing. See also the comments about multiple patterns versus |
| 172 |
|
a single pattern with alternatives in the description of \fB-e\fP above. |
| 173 |
.TP |
.TP |
| 174 |
\fB--file-offsets\fP |
\fB--file-offsets\fP |
| 175 |
Instead of showing lines or parts of lines that match, show each match as an |
Instead of showing lines or parts of lines that match, show each match as an |
| 423 |
.rs |
.rs |
| 424 |
.sp |
.sp |
| 425 |
.nf |
.nf |
| 426 |
Last updated: 05 December 2007 |
Last updated: 07 December 2007 |
| 427 |
Copyright (c) 1997-2007 University of Cambridge. |
Copyright (c) 1997-2007 University of Cambridge. |
| 428 |
.fi |
.fi |