| 23 |
.sp |
.sp |
| 24 |
If you attempt to use delimiters (for example, by surrounding a pattern with |
If you attempt to use delimiters (for example, by surrounding a pattern with |
| 25 |
slashes, as is common in Perl scripts), they are interpreted as part of the |
slashes, as is common in Perl scripts), they are interpreted as part of the |
| 26 |
pattern. Quotes can of course be used on the command line because they are |
pattern. Quotes can of course be used to delimit patterns on the command line |
| 27 |
interpreted by the shell, and indeed they are required if a pattern contains |
because they are interpreted by the shell, and indeed they are required if a |
| 28 |
white space or shell metacharacters. |
pattern contains white space or shell metacharacters. |
| 29 |
.P |
.P |
| 30 |
The first argument that follows any option settings is treated as the single |
The first argument that follows any option settings is treated as the single |
| 31 |
pattern to be matched when neither \fB-e\fP nor \fB-f\fP is present. |
pattern to be matched when neither \fB-e\fP nor \fB-f\fP is present. |
| 41 |
.sp |
.sp |
| 42 |
By default, each line that matches the pattern is copied to the standard |
By default, each line that matches the 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. However, there are options that can change how |
start of each line, followed by a colon. However, there are options that can |
| 45 |
\fBpcregrep\fP behaves. In particular, the \fB-M\fP option makes it possible to |
change how \fBpcregrep\fP behaves. In particular, the \fB-M\fP option makes it |
| 46 |
search for patterns that span line boundaries. What defines a line boundary is |
possible to search for patterns that span line boundaries. What defines a line |
| 47 |
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. |
| 116 |
are read as if they were ordinary files. In some operating systems the effect |
are read as if they were ordinary files. In some operating systems the effect |
| 117 |
of reading a directory like this is an immediate end-of-file. |
of reading a directory like this is an immediate end-of-file. |
| 118 |
.TP |
.TP |
| 119 |
\fB-e\fP \fIpattern\fP, \fB--regex=\fP\fIpattern\fP, |
\fB-e\fP \fIpattern\fP, \fB--regex=\fP\fIpattern\fP, \fB--regexp=\fP\fIpattern\fP |
| 120 |
\fB--regexp=\fP\fIpattern\fP Specify a pattern to be matched. This option can |
Specify a pattern to be matched. This option can be used multiple times in |
| 121 |
be used multiple times in order to specify several patterns. It can also be |
order to specify several patterns. It can also be used as a way of specifying a |
| 122 |
used as a way of specifying a single pattern that starts with a hyphen. When |
single pattern that starts with a hyphen. When \fB-e\fP is used, no argument |
| 123 |
\fB-e\fP is used, no argument pattern is taken from the command line; all |
pattern is taken from the command line; all arguments are treated as file |
| 124 |
arguments are treated as file names. There is an overall maximum of 100 |
names. There is an overall maximum of 100 patterns. They are applied to each |
| 125 |
patterns. They are applied to each line in the order in which they are defined |
line in the order in which they are defined until one matches (or fails to |
| 126 |
until one matches (or fails to match if \fB-v\fP is used). If \fB-f\fP is used |
match if \fB-v\fP is used). If \fB-f\fP is used with \fB-e\fP, the command line |
| 127 |
with \fB-e\fP, the command line patterns are matched first, followed by the |
patterns are matched first, followed by the patterns from the file, independent |
| 128 |
patterns from the file, independent of the order in which these options are |
of the order in which these options are specified. Note that multiple use of |
| 129 |
specified. Note that multiple use of \fB-e\fP is not the same as a single |
\fB-e\fP is not the same as a single pattern with alternatives. For example, |
| 130 |
pattern with alternatives. For example, X|Y finds the first character in a line |
X|Y finds the first character in a line that is X or Y, whereas if the two |
| 131 |
that is X or Y, whereas if the two patterns are given separately, |
patterns are given separately, \fBpcregrep\fP finds X if it is present, even if |
| 132 |
\fBpcregrep\fP finds X if it is present, even if it follows Y in the line. It |
it follows Y in the line. It finds Y only if there is no X in the line. This |
| 133 |
finds Y only if there is no X in the line. This really matters only if you are |
really matters only if you are using \fB-o\fP to show the part(s) of the line |
| 134 |
using \fB-o\fP to show the portion of the line that matched. |
that matched. |
| 135 |
.TP |
.TP |
| 136 |
\fB--exclude\fP=\fIpattern\fP |
\fB--exclude\fP=\fIpattern\fP |
| 137 |
When \fBpcregrep\fP is searching the files in a directory as a consequence of |
When \fBpcregrep\fP is searching the files in a directory as a consequence of |
| 220 |
are guaranteed to be available for lookbehind assertions. |
are guaranteed to be available for lookbehind assertions. |
| 221 |
.TP |
.TP |
| 222 |
\fB-N\fP \fInewline-type\fP, \fB--newline=\fP\fInewline-type\fP |
\fB-N\fP \fInewline-type\fP, \fB--newline=\fP\fInewline-type\fP |
| 223 |
The PCRE library supports four different conventions for indicating |
The PCRE library supports five different conventions for indicating |
| 224 |
the ends of lines. They are the single-character sequences CR (carriage return) |
the ends of lines. They are the single-character sequences CR (carriage return) |
| 225 |
and LF (linefeed), the two-character sequence CRLF, and an "any" convention, in |
and LF (linefeed), the two-character sequence CRLF, an "anycrlf" convention, |
| 226 |
|
which recognizes any of the preceding three types, and an "any" convention, in |
| 227 |
which any Unicode line ending sequence is assumed to end a line. The Unicode |
which any Unicode line ending sequence is assumed to end a line. The Unicode |
| 228 |
sequences are the three just mentioned, plus VT (vertical tab, U+000B), FF |
sequences are the three just mentioned, plus VT (vertical tab, U+000B), FF |
| 229 |
(formfeed, U+000C), NEL (next line, U+0085), LS (line separator, U+2028), and |
(formfeed, U+000C), NEL (next line, U+0085), LS (line separator, U+2028), and |
| 230 |
PS (paragraph separator, U+0029). |
PS (paragraph separator, U+2029). |
| 231 |
.sp |
.sp |
| 232 |
When the PCRE library is built, a default line-ending sequence is specified. |
When the PCRE library is built, a default line-ending sequence is specified. |
| 233 |
This is normally the standard sequence for the operating system. Unless |
This is normally the standard sequence for the operating system. Unless |
| 234 |
otherwise specified by this option, \fBpcregrep\fP uses the library's default. |
otherwise specified by this option, \fBpcregrep\fP uses the library's default. |
| 235 |
The possible values for this option are CR, LF, CRLF, or ANY. This makes it |
The possible values for this option are CR, LF, CRLF, ANYCRLF, or ANY. This |
| 236 |
possible to use \fBpcregrep\fP on files that have come from other environments |
makes it possible to use \fBpcregrep\fP on files that have come from other |
| 237 |
without having to modify their line endings. If the data that is being scanned |
environments without having to modify their line endings. If the data that is |
| 238 |
does not agree with the convention set by this option, \fBpcregrep\fP may |
being scanned does not agree with the convention set by this option, |
| 239 |
behave in strange ways. |
\fBpcregrep\fP may behave in strange ways. |
| 240 |
.TP |
.TP |
| 241 |
\fB-n\fP, \fB--line-number\fP |
\fB-n\fP, \fB--line-number\fP |
| 242 |
Precede each output line by its line number in the file, followed by a colon |
Precede each output line by its line number in the file, followed by a colon |
| 246 |
\fB-o\fP, \fB--only-matching\fP |
\fB-o\fP, \fB--only-matching\fP |
| 247 |
Show only the part of the line that matched a pattern. In this mode, no |
Show only the part of the line that matched a pattern. In this mode, no |
| 248 |
context is shown. That is, the \fB-A\fP, \fB-B\fP, and \fB-C\fP options are |
context is shown. That is, the \fB-A\fP, \fB-B\fP, and \fB-C\fP options are |
| 249 |
ignored. |
ignored. If there is more than one match in a line, each of them is shown |
| 250 |
|
separately. If \fB-o\fP is combined with \fB-v\fP (invert the sense of the |
| 251 |
|
match to find non-matching lines), no output is generated, but the return code |
| 252 |
|
is set appropriately. |
| 253 |
.TP |
.TP |
| 254 |
\fB-q\fP, \fB--quiet\fP |
\fB-q\fP, \fB--quiet\fP |
| 255 |
Work quietly, that is, display nothing except error messages. The exit |
Work quietly, that is, display nothing except error messages. The exit |
| 391 |
.rs |
.rs |
| 392 |
.sp |
.sp |
| 393 |
.nf |
.nf |
| 394 |
Last updated: 06 March 2007 |
Last updated: 04 December 2007 |
| 395 |
Copyright (c) 1997-2007 University of Cambridge. |
Copyright (c) 1997-2007 University of Cambridge. |
| 396 |
.fi |
.fi |