| 11 |
grep commands do, but it uses the PCRE regular expression library to support |
grep commands do, but it uses the PCRE regular expression library to support |
| 12 |
patterns that are compatible with the regular expressions of Perl 5. See |
patterns that are compatible with the regular expressions of Perl 5. See |
| 13 |
.\" HREF |
.\" HREF |
| 14 |
\fBpcrepattern\fP |
\fBpcrepattern\fP(3) |
| 15 |
.\" |
.\" |
| 16 |
for a full description of syntax and semantics of the regular expressions that |
for a full description of syntax and semantics of the regular expressions |
| 17 |
PCRE supports. |
that PCRE supports. |
| 18 |
.P |
.P |
| 19 |
Patterns, whether supplied on the command line or in a separate file, are given |
Patterns, whether supplied on the command line or in a separate file, are given |
| 20 |
without delimiters. For example: |
without delimiters. For example: |
| 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. |
| 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. 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. |
possible to search for patterns that span line boundaries. What defines a line |
| 47 |
|
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. |
| 54 |
|
.P |
| 55 |
|
By default, as soon as one pattern matches (or fails to match when \fB-v\fP is |
| 56 |
|
used), no further patterns are considered. However, if \fB--colour\fP (or |
| 57 |
|
\fB--color\fP) is used to colour the matching substrings, or if |
| 58 |
|
\fB--only-matching\fP, \fB--file-offsets\fP, or \fB--line-offsets\fP is used to |
| 59 |
|
output only the part of the line that matched (either shown literally, or as an |
| 60 |
|
offset), scanning resumes immediately following the match, so that further |
| 61 |
|
matches on the same line can be found. If there are multiple patterns, they are |
| 62 |
|
all tried on the remainder of the line, but patterns that follow the one that |
| 63 |
|
matched are not tried on the earlier part of the line. |
| 64 |
|
.P |
| 65 |
|
This is the same behaviour as GNU grep, but it does mean that the order in |
| 66 |
|
which multiple patterns are specified can affect the output when one of the |
| 67 |
|
above options is used. |
| 68 |
|
.P |
| 69 |
|
Patterns that can match an empty string are accepted, but empty string |
| 70 |
|
matches are never recognized. An example is the pattern "(super)?(man)?", in |
| 71 |
|
which all components are optional. This pattern finds all occurrences of both |
| 72 |
|
"super" and "man"; the output differs from matching with "super|man" when only |
| 73 |
|
the matching substrings are being shown. |
| 74 |
.P |
.P |
| 75 |
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, |
| 76 |
\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. |
| 77 |
The \fB--locale\fP option can be used to override this. |
The \fB--locale\fP option can be used to override this. |
| 78 |
. |
. |
| 79 |
|
.SH "SUPPORT FOR COMPRESSED FILES" |
| 80 |
|
.rs |
| 81 |
|
.sp |
| 82 |
|
It is possible to compile \fBpcregrep\fP so that it uses \fBlibz\fP or |
| 83 |
|
\fBlibbz2\fP to read files whose names end in \fB.gz\fP or \fB.bz2\fP, |
| 84 |
|
respectively. You can find out whether your binary has support for one or both |
| 85 |
|
of these file types by running it with the \fB--help\fP option. If the |
| 86 |
|
appropriate support is not present, files are treated as plain text. The |
| 87 |
|
standard input is always so treated. |
| 88 |
|
. |
| 89 |
.SH OPTIONS |
.SH OPTIONS |
| 90 |
.rs |
.rs |
| 91 |
|
.sp |
| 92 |
|
The order in which some of the options appear can affect the output. For |
| 93 |
|
example, both the \fB-h\fP and \fB-l\fP options affect the printing of file |
| 94 |
|
names. Whichever comes later in the command line will be the one that takes |
| 95 |
|
effect. |
| 96 |
.TP 10 |
.TP 10 |
| 97 |
\fB--\fP |
\fB--\fP |
| 98 |
This terminate the list of options. It is useful if the next item on the |
This terminate the list of options. It is useful if the next item on the |
| 120 |
This is equivalent to setting both \fB-A\fP and \fB-B\fP to the same value. |
This is equivalent to setting both \fB-A\fP and \fB-B\fP to the same value. |
| 121 |
.TP |
.TP |
| 122 |
\fB-c\fP, \fB--count\fP |
\fB-c\fP, \fB--count\fP |
| 123 |
Do not output individual lines; instead just output a count of the number of |
Do not output individual lines from the files that are being scanned; instead |
| 124 |
lines that would otherwise have been output. If several files are given, a |
output the number of lines that would otherwise have been shown. If no lines |
| 125 |
count is output for each of them. In this mode, the \fB-A\fP, \fB-B\fP, and |
are selected, the number zero is output. If several files are are being |
| 126 |
\fB-C\fP options are ignored. |
scanned, a count is output for each of them. However, if the |
| 127 |
|
\fB--files-with-matches\fP option is also used, only those files whose counts |
| 128 |
|
are greater than zero are listed. When \fB-c\fP is used, the \fB-A\fP, |
| 129 |
|
\fB-B\fP, and \fB-C\fP options are ignored. |
| 130 |
.TP |
.TP |
| 131 |
\fB--colour\fP, \fB--color\fP |
\fB--colour\fP, \fB--color\fP |
| 132 |
If this option is given without any data, it is equivalent to "--colour=auto". |
If this option is given without any data, it is equivalent to "--colour=auto". |
| 134 |
equals sign. |
equals sign. |
| 135 |
.TP |
.TP |
| 136 |
\fB--colour=\fP\fIvalue\fP, \fB--color=\fP\fIvalue\fP |
\fB--colour=\fP\fIvalue\fP, \fB--color=\fP\fIvalue\fP |
| 137 |
This option specifies under what circumstances the part of a line that matched |
This option specifies under what circumstances the parts of a line that matched |
| 138 |
a pattern should be coloured in the output. The value may be "never" (the |
a pattern should be coloured in the output. By default, the output is not |
| 139 |
default), "always", or "auto". In the latter case, colouring happens only if |
coloured. The value (which is optional, see above) may be "never", "always", or |
| 140 |
the standard output is connected to a terminal. The colour can be specified by |
"auto". In the latter case, colouring happens only if the standard output is |
| 141 |
setting the environment variable PCREGREP_COLOUR or PCREGREP_COLOR. The value |
connected to a terminal. More resources are used when colouring is enabled, |
| 142 |
of this variable should be a string of two numbers, separated by a semicolon. |
because \fBpcregrep\fP has to search for all possible matches in a line, not |
| 143 |
They are copied directly into the control string for setting colour on a |
just one, in order to colour them all. |
| 144 |
terminal, so it is your responsibility to ensure that they make sense. If |
|
| 145 |
neither of the environment variables is set, the default is "1;31", which gives |
The colour that is used can be specified by setting the environment variable |
| 146 |
red. |
PCREGREP_COLOUR or PCREGREP_COLOR. The value of this variable should be a |
| 147 |
|
string of two numbers, separated by a semicolon. They are copied directly into |
| 148 |
|
the control string for setting colour on a terminal, so it is your |
| 149 |
|
responsibility to ensure that they make sense. If neither of the environment |
| 150 |
|
variables is set, the default is "1;31", which gives red. |
| 151 |
.TP |
.TP |
| 152 |
\fB-D\fP \fIaction\fP, \fB--devices=\fP\fIaction\fP |
\fB-D\fP \fIaction\fP, \fB--devices=\fP\fIaction\fP |
| 153 |
If an input path is not a regular file or a directory, "action" specifies how |
If an input path is not a regular file or a directory, "action" specifies how |
| 161 |
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 |
| 162 |
of reading a directory like this is an immediate end-of-file. |
of reading a directory like this is an immediate end-of-file. |
| 163 |
.TP |
.TP |
| 164 |
\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 |
| 165 |
\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 |
| 166 |
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 |
| 167 |
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 |
| 168 |
\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 |
| 169 |
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 |
| 170 |
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 |
| 171 |
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 |
| 172 |
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 |
| 173 |
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 |
| 174 |
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, |
| 175 |
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 |
| 176 |
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 |
| 177 |
\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 |
| 178 |
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 |
| 179 |
using \fB-o\fP to show the portion of the line that matched. |
that matched. |
| 180 |
.TP |
.TP |
| 181 |
\fB--exclude\fP=\fIpattern\fP |
\fB--exclude\fP=\fIpattern\fP |
| 182 |
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 |
| 183 |
the \fB-r\fP (recursive search) option, any files whose names match the pattern |
the \fB-r\fP (recursive search) option, any regular files whose names match the |
| 184 |
are excluded. The pattern is a PCRE regular expression. If a file name matches |
pattern are excluded. Subdirectories are not excluded by this option; they are |
| 185 |
both \fB--include\fP and \fB--exclude\fP, it is excluded. There is no short |
searched recursively, subject to the \fB--exclude_dir\fP and |
| 186 |
form for this option. |
\fB--include_dir\fP options. The pattern is a PCRE regular expression, and is |
| 187 |
|
matched against the final component of the file name (not the entire path). If |
| 188 |
|
a file name matches both \fB--include\fP and \fB--exclude\fP, it is excluded. |
| 189 |
|
There is no short form for this option. |
| 190 |
|
.TP |
| 191 |
|
\fB--exclude_dir\fP=\fIpattern\fP |
| 192 |
|
When \fBpcregrep\fP is searching the contents of a directory as a consequence |
| 193 |
|
of the \fB-r\fP (recursive search) option, any subdirectories whose names match |
| 194 |
|
the pattern are excluded. (Note that the \fP--exclude\fP option does not affect |
| 195 |
|
subdirectories.) The pattern is a PCRE regular expression, and is matched |
| 196 |
|
against the final component of the name (not the entire path). If a |
| 197 |
|
subdirectory name matches both \fB--include_dir\fP and \fB--exclude_dir\fP, it |
| 198 |
|
is excluded. There is no short form for this option. |
| 199 |
.TP |
.TP |
| 200 |
\fB-F\fP, \fB--fixed-strings\fP |
\fB-F\fP, \fB--fixed-strings\fP |
| 201 |
Interpret each pattern as a list of fixed strings, separated by newlines, |
Interpret each pattern as a list of fixed strings, separated by newlines, |
| 213 |
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 |
| 214 |
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 |
| 215 |
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 |
| 216 |
therefore matches nothing. |
therefore matches nothing. See also the comments about multiple patterns versus |
| 217 |
|
a single pattern with alternatives in the description of \fB-e\fP above. |
| 218 |
|
.TP |
| 219 |
|
\fB--file-offsets\fP |
| 220 |
|
Instead of showing lines or parts of lines that match, show each match as an |
| 221 |
|
offset from the start of the file and a length, separated by a comma. In this |
| 222 |
|
mode, no context is shown. That is, the \fB-A\fP, \fB-B\fP, and \fB-C\fP |
| 223 |
|
options are ignored. If there is more than one match in a line, each of them is |
| 224 |
|
shown separately. This option is mutually exclusive with \fB--line-offsets\fP |
| 225 |
|
and \fB--only-matching\fP. |
| 226 |
.TP |
.TP |
| 227 |
\fB-H\fP, \fB--with-filename\fP |
\fB-H\fP, \fB--with-filename\fP |
| 228 |
Force the inclusion of the filename at the start of output lines when searching |
Force the inclusion of the filename at the start of output lines when searching |
| 229 |
a single file. By default, the filename is not shown in this case. For matching |
a single file. By default, the filename is not shown in this case. For matching |
| 230 |
lines, the filename is followed by a colon and a space; for context lines, a |
lines, the filename is followed by a colon; for context lines, a hyphen |
| 231 |
hyphen separator is used. If a line number is also being output, it follows the |
separator is used. If a line number is also being output, it follows the file |
| 232 |
file name without a space. |
name. |
| 233 |
.TP |
.TP |
| 234 |
\fB-h\fP, \fB--no-filename\fP |
\fB-h\fP, \fB--no-filename\fP |
| 235 |
Suppress the output filenames when searching multiple files. By default, |
Suppress the output filenames when searching multiple files. By default, |
| 236 |
filenames are shown when multiple files are searched. For matching lines, the |
filenames are shown when multiple files are searched. For matching lines, the |
| 237 |
filename is followed by a colon and a space; for context lines, a hyphen |
filename is followed by a colon; for context lines, a hyphen separator is used. |
| 238 |
separator is used. If a line number is also being output, it follows the file |
If a line number is also being output, it follows the file name. |
|
name without a space. |
|
| 239 |
.TP |
.TP |
| 240 |
\fB--help\fP |
\fB--help\fP |
| 241 |
Output a brief help message and exit. |
Output a help message, giving brief details of the command options and file |
| 242 |
|
type support, and then exit. |
| 243 |
.TP |
.TP |
| 244 |
\fB-i\fP, \fB--ignore-case\fP |
\fB-i\fP, \fB--ignore-case\fP |
| 245 |
Ignore upper/lower case distinctions during comparisons. |
Ignore upper/lower case distinctions during comparisons. |
| 246 |
.TP |
.TP |
| 247 |
\fB--include\fP=\fIpattern\fP |
\fB--include\fP=\fIpattern\fP |
| 248 |
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 |
| 249 |
the \fB-r\fP (recursive search) option, only those files whose names match the |
the \fB-r\fP (recursive search) option, only those regular files whose names |
| 250 |
pattern are included. The pattern is a PCRE regular expression. If a file name |
match the pattern are included. Subdirectories are always included and searched |
| 251 |
matches both \fB--include\fP and \fB--exclude\fP, it is excluded. There is no |
recursively, subject to the \fP--include_dir\fP and \fB--exclude_dir\fP |
| 252 |
short form for this option. |
options. The pattern is a PCRE regular expression, and is matched against the |
| 253 |
|
final component of the file name (not the entire path). If a file name matches |
| 254 |
|
both \fB--include\fP and \fB--exclude\fP, it is excluded. There is no short |
| 255 |
|
form for this option. |
| 256 |
|
.TP |
| 257 |
|
\fB--include_dir\fP=\fIpattern\fP |
| 258 |
|
When \fBpcregrep\fP is searching the contents of a directory as a consequence |
| 259 |
|
of the \fB-r\fP (recursive search) option, only those subdirectories whose |
| 260 |
|
names match the pattern are included. (Note that the \fB--include\fP option |
| 261 |
|
does not affect subdirectories.) The pattern is a PCRE regular expression, and |
| 262 |
|
is matched against the final component of the name (not the entire path). If a |
| 263 |
|
subdirectory name matches both \fB--include_dir\fP and \fB--exclude_dir\fP, it |
| 264 |
|
is excluded. There is no short form for this option. |
| 265 |
.TP |
.TP |
| 266 |
\fB-L\fP, \fB--files-without-match\fP |
\fB-L\fP, \fB--files-without-match\fP |
| 267 |
Instead of outputting lines from the files, just output the names of the files |
Instead of outputting lines from the files, just output the names of the files |
| 271 |
\fB-l\fP, \fB--files-with-matches\fP |
\fB-l\fP, \fB--files-with-matches\fP |
| 272 |
Instead of outputting lines from the files, just output the names of the files |
Instead of outputting lines from the files, just output the names of the files |
| 273 |
containing lines that would have been output. Each file name is output |
containing lines that would have been output. Each file name is output |
| 274 |
once, on a separate line. Searching stops as soon as a matching line is found |
once, on a separate line. Searching normally stops as soon as a matching line |
| 275 |
in a file. |
is found in a file. However, if the \fB-c\fP (count) option is also used, |
| 276 |
|
matching continues in order to obtain the correct count, and those files that |
| 277 |
|
have at least one match are listed along with their counts. Using this option |
| 278 |
|
with \fB-c\fP is a way of suppressing the listing of files with no matches. |
| 279 |
.TP |
.TP |
| 280 |
\fB--label\fP=\fIname\fP |
\fB--label\fP=\fIname\fP |
| 281 |
This option supplies a name to be used for the standard input when file names |
This option supplies a name to be used for the standard input when file names |
| 282 |
are being output. If not supplied, "(standard input)" is used. There is no |
are being output. If not supplied, "(standard input)" is used. There is no |
| 283 |
short form for this option. |
short form for this option. |
| 284 |
.TP |
.TP |
| 285 |
|
\fB--line-offsets\fP |
| 286 |
|
Instead of showing lines or parts of lines that match, show each match as a |
| 287 |
|
line number, the offset from the start of the line, and a length. The line |
| 288 |
|
number is terminated by a colon (as usual; see the \fB-n\fP option), and the |
| 289 |
|
offset and length are separated by a comma. In this mode, no context is shown. |
| 290 |
|
That is, the \fB-A\fP, \fB-B\fP, and \fB-C\fP options are ignored. If there is |
| 291 |
|
more than one match in a line, each of them is shown separately. This option is |
| 292 |
|
mutually exclusive with \fB--file-offsets\fP and \fB--only-matching\fP. |
| 293 |
|
.TP |
| 294 |
\fB--locale\fP=\fIlocale-name\fP |
\fB--locale\fP=\fIlocale-name\fP |
| 295 |
This option specifies a locale to be used for pattern matching. It overrides |
This option specifies a locale to be used for pattern matching. It overrides |
| 296 |
the value in the \fBLC_ALL\fP or \fBLC_CTYPE\fP environment variables. If no |
the value in the \fBLC_ALL\fP or \fBLC_CTYPE\fP environment variables. If no |
| 309 |
the previous 8K characters (or all the previous characters, if fewer than 8K) |
the previous 8K characters (or all the previous characters, if fewer than 8K) |
| 310 |
are guaranteed to be available for lookbehind assertions. |
are guaranteed to be available for lookbehind assertions. |
| 311 |
.TP |
.TP |
| 312 |
|
\fB-N\fP \fInewline-type\fP, \fB--newline=\fP\fInewline-type\fP |
| 313 |
|
The PCRE library supports five different conventions for indicating |
| 314 |
|
the ends of lines. They are the single-character sequences CR (carriage return) |
| 315 |
|
and LF (linefeed), the two-character sequence CRLF, an "anycrlf" convention, |
| 316 |
|
which recognizes any of the preceding three types, and an "any" convention, in |
| 317 |
|
which any Unicode line ending sequence is assumed to end a line. The Unicode |
| 318 |
|
sequences are the three just mentioned, plus VT (vertical tab, U+000B), FF |
| 319 |
|
(formfeed, U+000C), NEL (next line, U+0085), LS (line separator, U+2028), and |
| 320 |
|
PS (paragraph separator, U+2029). |
| 321 |
|
.sp |
| 322 |
|
When the PCRE library is built, a default line-ending sequence is specified. |
| 323 |
|
This is normally the standard sequence for the operating system. Unless |
| 324 |
|
otherwise specified by this option, \fBpcregrep\fP uses the library's default. |
| 325 |
|
The possible values for this option are CR, LF, CRLF, ANYCRLF, or ANY. This |
| 326 |
|
makes it possible to use \fBpcregrep\fP on files that have come from other |
| 327 |
|
environments without having to modify their line endings. If the data that is |
| 328 |
|
being scanned does not agree with the convention set by this option, |
| 329 |
|
\fBpcregrep\fP may behave in strange ways. |
| 330 |
|
.TP |
| 331 |
\fB-n\fP, \fB--line-number\fP |
\fB-n\fP, \fB--line-number\fP |
| 332 |
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 |
| 333 |
and a space for matching lines or a hyphen and a space for context lines. If |
for matching lines or a hyphen for context lines. If the filename is also being |
| 334 |
the filename is also being output, it precedes the line number. |
output, it precedes the line number. This option is forced if |
| 335 |
|
\fB--line-offsets\fP is used. |
| 336 |
.TP |
.TP |
| 337 |
\fB-o\fP, \fB--only-matching\fP |
\fB-o\fP, \fB--only-matching\fP |
| 338 |
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 |
| 339 |
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 |
| 340 |
ignored. |
ignored. If there is more than one match in a line, each of them is shown |
| 341 |
|
separately. If \fB-o\fP is combined with \fB-v\fP (invert the sense of the |
| 342 |
|
match to find non-matching lines), no output is generated, but the return code |
| 343 |
|
is set appropriately. This option is mutually exclusive with |
| 344 |
|
\fB--file-offsets\fP and \fB--line-offsets\fP. |
| 345 |
.TP |
.TP |
| 346 |
\fB-q\fP, \fB--quiet\fP |
\fB-q\fP, \fB--quiet\fP |
| 347 |
Work quietly, that is, display nothing except error messages. The exit |
Work quietly, that is, display nothing except error messages. The exit |
| 376 |
Force the patterns to match only whole words. This is equivalent to having \eb |
Force the patterns to match only whole words. This is equivalent to having \eb |
| 377 |
at the start and end of the pattern. |
at the start and end of the pattern. |
| 378 |
.TP |
.TP |
| 379 |
\fB-x\fP, \fB--line-regex\fP, \fP--line-regexp\fP |
\fB-x\fP, \fB--line-regex\fP, \fB--line-regexp\fP |
| 380 |
Force the patterns to be anchored (each must start matching at the beginning of |
Force the patterns to be anchored (each must start matching at the beginning of |
| 381 |
a line) and in addition, require them to match entire lines. This is |
a line) and in addition, require them to match entire lines. This is |
| 382 |
equivalent to having ^ and $ characters at the start and end of each |
equivalent to having ^ and $ characters at the start and end of each |
| 392 |
(usually the "C" locale) is used. |
(usually the "C" locale) is used. |
| 393 |
. |
. |
| 394 |
. |
. |
| 395 |
|
.SH "NEWLINES" |
| 396 |
|
.rs |
| 397 |
|
.sp |
| 398 |
|
The \fB-N\fP (\fB--newline\fP) option allows \fBpcregrep\fP to scan files with |
| 399 |
|
different newline conventions from the default. However, the setting of this |
| 400 |
|
option does not affect the way in which \fBpcregrep\fP writes information to |
| 401 |
|
the standard error and output streams. It uses the string "\en" in C |
| 402 |
|
\fBprintf()\fP calls to indicate newlines, relying on the C I/O library to |
| 403 |
|
convert this to an appropriate sequence if the output is sent to a file. |
| 404 |
|
. |
| 405 |
|
. |
| 406 |
.SH "OPTIONS COMPATIBILITY" |
.SH "OPTIONS COMPATIBILITY" |
| 407 |
.rs |
.rs |
| 408 |
.sp |
.sp |
| 410 |
as in the GNU \fBgrep\fP program. Any long option of the form |
as in the GNU \fBgrep\fP program. Any long option of the form |
| 411 |
\fB--xxx-regexp\fP (GNU terminology) is also available as \fB--xxx-regex\fP |
\fB--xxx-regexp\fP (GNU terminology) is also available as \fB--xxx-regex\fP |
| 412 |
(PCRE terminology). However, the \fB--locale\fP, \fB-M\fP, \fB--multiline\fP, |
(PCRE terminology). However, the \fB--locale\fP, \fB-M\fP, \fB--multiline\fP, |
| 413 |
\fB-u\fP, and \fB--utf-8\fP options are specific to \fBpcregrep\fP. |
\fB-u\fP, and \fB--utf-8\fP options are specific to \fBpcregrep\fP. If both the |
| 414 |
|
\fB-c\fP and \fB-l\fP options are given, GNU grep lists only file names, |
| 415 |
|
without counts, but \fBpcregrep\fP gives the counts. |
| 416 |
. |
. |
| 417 |
. |
. |
| 418 |
.SH "OPTIONS WITH DATA" |
.SH "OPTIONS WITH DATA" |
| 443 |
it has no data. |
it has no data. |
| 444 |
. |
. |
| 445 |
. |
. |
| 446 |
.SH MATCHING ERRORS |
.SH "MATCHING ERRORS" |
| 447 |
.rs |
.rs |
| 448 |
.sp |
.sp |
| 449 |
It is possible to supply a regular expression that takes a very long time to |
It is possible to supply a regular expression that takes a very long time to |
| 465 |
code. |
code. |
| 466 |
. |
. |
| 467 |
. |
. |
| 468 |
|
.SH "SEE ALSO" |
| 469 |
|
.rs |
| 470 |
|
.sp |
| 471 |
|
\fBpcrepattern\fP(3), \fBpcretest\fP(1). |
| 472 |
|
. |
| 473 |
|
. |
| 474 |
.SH AUTHOR |
.SH AUTHOR |
| 475 |
.rs |
.rs |
| 476 |
.sp |
.sp |
| 477 |
|
.nf |
| 478 |
Philip Hazel |
Philip Hazel |
|
.br |
|
| 479 |
University Computing Service |
University Computing Service |
| 480 |
.br |
Cambridge CB2 3QH, England. |
| 481 |
Cambridge CB2 3QG, England. |
.fi |
| 482 |
.P |
. |
| 483 |
.in 0 |
. |
| 484 |
Last updated: 23 January 2006 |
.SH REVISION |
| 485 |
.br |
.rs |
| 486 |
Copyright (c) 1997-2006 University of Cambridge. |
.sp |
| 487 |
|
.nf |
| 488 |
|
Last updated: 13 September 2009 |
| 489 |
|
Copyright (c) 1997-2009 University of Cambridge. |
| 490 |
|
.fi |