| 7 |
<p> |
<p> |
| 8 |
Return to the <a href="index.html">PCRE index page</a>. |
Return to the <a href="index.html">PCRE index page</a>. |
| 9 |
</p> |
</p> |
| 10 |
<p> |
<p> |
| 11 |
This page is part of the PCRE HTML documentation. It was generated automatically |
This page is part of the PCRE HTML documentation. It was generated automatically |
| 12 |
from the original man page. If there is any nonsense in it, please consult the |
from the original man page. If there is any nonsense in it, please consult the |
| 13 |
man page, in case the conversion went wrong. |
man page, in case the conversion went wrong. |
| 14 |
<br> |
<br> |
| 15 |
<ul> |
<ul> |
| 16 |
<li><a name="TOC1" href="#SEC1">SYNOPSIS</a> |
<li><a name="TOC1" href="#SEC1">SYNOPSIS</a> |
| 17 |
<li><a name="TOC2" href="#SEC2">DESCRIPTION</a> |
<li><a name="TOC2" href="#SEC2">DESCRIPTION</a> |
| 18 |
<li><a name="TOC3" href="#SEC3">OPTIONS</a> |
<li><a name="TOC3" href="#SEC3">OPTIONS</a> |
| 19 |
<li><a name="TOC4" href="#SEC4">ENVIRONMENT VARIABLES</a> |
<li><a name="TOC4" href="#SEC4">ENVIRONMENT VARIABLES</a> |
| 20 |
<li><a name="TOC5" href="#SEC5">OPTIONS COMPATIBILITY</a> |
<li><a name="TOC5" href="#SEC5">NEWLINES</a> |
| 21 |
<li><a name="TOC6" href="#SEC6">OPTIONS WITH DATA</a> |
<li><a name="TOC6" href="#SEC6">OPTIONS COMPATIBILITY</a> |
| 22 |
<li><a name="TOC7" href="#SEC7">MATCHING ERRORS</a> |
<li><a name="TOC7" href="#SEC7">OPTIONS WITH DATA</a> |
| 23 |
<li><a name="TOC8" href="#SEC8">DIAGNOSTICS</a> |
<li><a name="TOC8" href="#SEC8">MATCHING ERRORS</a> |
| 24 |
<li><a name="TOC9" href="#SEC9">AUTHOR</a> |
<li><a name="TOC9" href="#SEC9">DIAGNOSTICS</a> |
| 25 |
|
<li><a name="TOC10" href="#SEC10">SEE ALSO</a> |
| 26 |
|
<li><a name="TOC11" href="#SEC11">AUTHOR</a> |
| 27 |
|
<li><a name="TOC12" href="#SEC12">REVISION</a> |
| 28 |
</ul> |
</ul> |
| 29 |
<br><a name="SEC1" href="#TOC1">SYNOPSIS</a><br> |
<br><a name="SEC1" href="#TOC1">SYNOPSIS</a><br> |
| 30 |
<P> |
<P> |
| 35 |
<b>pcregrep</b> searches files for character patterns, in the same way as other |
<b>pcregrep</b> searches files for character patterns, in the same way as other |
| 36 |
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 |
| 37 |
patterns that are compatible with the regular expressions of Perl 5. See |
patterns that are compatible with the regular expressions of Perl 5. See |
| 38 |
<a href="pcrepattern.html"><b>pcrepattern</b></a> |
<a href="pcrepattern.html"><b>pcrepattern</b>(3)</a> |
| 39 |
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 |
| 40 |
PCRE supports. |
that PCRE supports. |
| 41 |
</P> |
</P> |
| 42 |
<P> |
<P> |
| 43 |
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 |
| 69 |
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 |
| 70 |
start of each line. However, there are options that can change how |
start of each line. However, there are options that can change how |
| 71 |
<b>pcregrep</b> behaves. In particular, the <b>-M</b> option makes it possible to |
<b>pcregrep</b> behaves. In particular, the <b>-M</b> option makes it possible to |
| 72 |
search for patterns that span line boundaries. |
search for patterns that span line boundaries. What defines a line boundary is |
| 73 |
|
controlled by the <b>-N</b> (<b>--newline</b>) option. |
| 74 |
</P> |
</P> |
| 75 |
<P> |
<P> |
| 76 |
Patterns are limited to 8K or BUFSIZ characters, whichever is the greater. |
Patterns are limited to 8K or BUFSIZ characters, whichever is the greater. |
| 269 |
are guaranteed to be available for lookbehind assertions. |
are guaranteed to be available for lookbehind assertions. |
| 270 |
</P> |
</P> |
| 271 |
<P> |
<P> |
| 272 |
|
<b>-N</b> <i>newline-type</i>, <b>--newline=</b><i>newline-type</i> |
| 273 |
|
The PCRE library supports four different conventions for indicating |
| 274 |
|
the ends of lines. They are the single-character sequences CR (carriage return) |
| 275 |
|
and LF (linefeed), the two-character sequence CRLF, and an "any" convention, in |
| 276 |
|
which any Unicode line ending sequence is assumed to end a line. The Unicode |
| 277 |
|
sequences are the three just mentioned, plus VT (vertical tab, U+000B), FF |
| 278 |
|
(formfeed, U+000C), NEL (next line, U+0085), LS (line separator, U+2028), and |
| 279 |
|
PS (paragraph separator, U+0029). |
| 280 |
|
<br> |
| 281 |
|
<br> |
| 282 |
|
When the PCRE library is built, a default line-ending sequence is specified. |
| 283 |
|
This is normally the standard sequence for the operating system. Unless |
| 284 |
|
otherwise specified by this option, <b>pcregrep</b> uses the library's default. |
| 285 |
|
The possible values for this option are CR, LF, CRLF, or ANY. This makes it |
| 286 |
|
possible to use <b>pcregrep</b> on files that have come from other environments |
| 287 |
|
without having to modify their line endings. If the data that is being scanned |
| 288 |
|
does not agree with the convention set by this option, <b>pcregrep</b> may |
| 289 |
|
behave in strange ways. |
| 290 |
|
</P> |
| 291 |
|
<P> |
| 292 |
<b>-n</b>, <b>--line-number</b> |
<b>-n</b>, <b>--line-number</b> |
| 293 |
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 |
| 294 |
and a space for matching lines or a hyphen and a space for context lines. If |
and a space for matching lines or a hyphen and a space for context lines. If |
| 354 |
by the <b>--locale</b> option. If no locale is set, the PCRE library's default |
by the <b>--locale</b> option. If no locale is set, the PCRE library's default |
| 355 |
(usually the "C" locale) is used. |
(usually the "C" locale) is used. |
| 356 |
</P> |
</P> |
| 357 |
<br><a name="SEC5" href="#TOC1">OPTIONS COMPATIBILITY</a><br> |
<br><a name="SEC5" href="#TOC1">NEWLINES</a><br> |
| 358 |
|
<P> |
| 359 |
|
The <b>-N</b> (<b>--newline</b>) option allows <b>pcregrep</b> to scan files with |
| 360 |
|
different newline conventions from the default. However, the setting of this |
| 361 |
|
option does not affect the way in which <b>pcregrep</b> writes information to |
| 362 |
|
the standard error and output streams. It uses the string "\n" in C |
| 363 |
|
<b>printf()</b> calls to indicate newlines, relying on the C I/O library to |
| 364 |
|
convert this to an appropriate sequence if the output is sent to a file. |
| 365 |
|
</P> |
| 366 |
|
<br><a name="SEC6" href="#TOC1">OPTIONS COMPATIBILITY</a><br> |
| 367 |
<P> |
<P> |
| 368 |
The majority of short and long forms of <b>pcregrep</b>'s options are the same |
The majority of short and long forms of <b>pcregrep</b>'s options are the same |
| 369 |
as in the GNU <b>grep</b> program. Any long option of the form |
as in the GNU <b>grep</b> program. Any long option of the form |
| 371 |
(PCRE terminology). However, the <b>--locale</b>, <b>-M</b>, <b>--multiline</b>, |
(PCRE terminology). However, the <b>--locale</b>, <b>-M</b>, <b>--multiline</b>, |
| 372 |
<b>-u</b>, and <b>--utf-8</b> options are specific to <b>pcregrep</b>. |
<b>-u</b>, and <b>--utf-8</b> options are specific to <b>pcregrep</b>. |
| 373 |
</P> |
</P> |
| 374 |
<br><a name="SEC6" href="#TOC1">OPTIONS WITH DATA</a><br> |
<br><a name="SEC7" href="#TOC1">OPTIONS WITH DATA</a><br> |
| 375 |
<P> |
<P> |
| 376 |
There are four different ways in which an option with data can be specified. |
There are four different ways in which an option with data can be specified. |
| 377 |
If a short form option is used, the data may follow immediately, or in the next |
If a short form option is used, the data may follow immediately, or in the next |
| 398 |
in the first form, using an equals character. Otherwise it will be assumed that |
in the first form, using an equals character. Otherwise it will be assumed that |
| 399 |
it has no data. |
it has no data. |
| 400 |
</P> |
</P> |
| 401 |
<br><a name="SEC7" href="#TOC1">MATCHING ERRORS</a><br> |
<br><a name="SEC8" href="#TOC1">MATCHING ERRORS</a><br> |
| 402 |
<P> |
<P> |
| 403 |
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 |
| 404 |
fail to match certain lines. Such patterns normally involve nested indefinite |
fail to match certain lines. Such patterns normally involve nested indefinite |
| 408 |
message and the line that caused the problem to the standard error stream. If |
message and the line that caused the problem to the standard error stream. If |
| 409 |
there are more than 20 such errors, <b>pcregrep</b> gives up. |
there are more than 20 such errors, <b>pcregrep</b> gives up. |
| 410 |
</P> |
</P> |
| 411 |
<br><a name="SEC8" href="#TOC1">DIAGNOSTICS</a><br> |
<br><a name="SEC9" href="#TOC1">DIAGNOSTICS</a><br> |
| 412 |
<P> |
<P> |
| 413 |
Exit status is 0 if any matches were found, 1 if no matches were found, and 2 |
Exit status is 0 if any matches were found, 1 if no matches were found, and 2 |
| 414 |
for syntax errors and non-existent or inacessible files (even if matches were |
for syntax errors and non-existent or inacessible files (even if matches were |
| 416 |
suppress error messages about inaccessble files does not affect the return |
suppress error messages about inaccessble files does not affect the return |
| 417 |
code. |
code. |
| 418 |
</P> |
</P> |
| 419 |
<br><a name="SEC9" href="#TOC1">AUTHOR</a><br> |
<br><a name="SEC10" href="#TOC1">SEE ALSO</a><br> |
| 420 |
|
<P> |
| 421 |
|
<b>pcrepattern</b>(3), <b>pcretest</b>(1). |
| 422 |
|
</P> |
| 423 |
|
<br><a name="SEC11" href="#TOC1">AUTHOR</a><br> |
| 424 |
<P> |
<P> |
| 425 |
Philip Hazel |
Philip Hazel |
| 426 |
<br> |
<br> |
| 427 |
University Computing Service |
University Computing Service |
| 428 |
<br> |
<br> |
| 429 |
Cambridge CB2 3QG, England. |
Cambridge CB2 3QH, England. |
| 430 |
|
<br> |
| 431 |
</P> |
</P> |
| 432 |
|
<br><a name="SEC12" href="#TOC1">REVISION</a><br> |
| 433 |
<P> |
<P> |
| 434 |
Last updated: 23 January 2006 |
Last updated: 06 March 2007 |
| 435 |
|
<br> |
| 436 |
|
Copyright © 1997-2007 University of Cambridge. |
| 437 |
<br> |
<br> |
|
Copyright © 1997-2006 University of Cambridge. |
|
| 438 |
<p> |
<p> |
| 439 |
Return to the <a href="index.html">PCRE index page</a>. |
Return to the <a href="index.html">PCRE index page</a>. |
| 440 |
</p> |
</p> |