version 1.1, 2012/02/21 23:05:52
|
version 1.1.1.2, 2012/10/09 09:19:18
|
Line 16 man page, in case the conversion went wrong.
|
Line 16 man page, in case the conversion went wrong.
|
<li><a name="TOC1" href="#SEC1">SYNOPSIS</a> |
<li><a name="TOC1" href="#SEC1">SYNOPSIS</a> |
<li><a name="TOC2" href="#SEC2">DESCRIPTION</a> |
<li><a name="TOC2" href="#SEC2">DESCRIPTION</a> |
<li><a name="TOC3" href="#SEC3">SUPPORT FOR COMPRESSED FILES</a> |
<li><a name="TOC3" href="#SEC3">SUPPORT FOR COMPRESSED FILES</a> |
<li><a name="TOC4" href="#SEC4">OPTIONS</a> | <li><a name="TOC4" href="#SEC4">BINARY FILES</a> |
<li><a name="TOC5" href="#SEC5">ENVIRONMENT VARIABLES</a> | <li><a name="TOC5" href="#SEC5">OPTIONS</a> |
<li><a name="TOC6" href="#SEC6">NEWLINES</a> | <li><a name="TOC6" href="#SEC6">ENVIRONMENT VARIABLES</a> |
<li><a name="TOC7" href="#SEC7">OPTIONS COMPATIBILITY</a> | <li><a name="TOC7" href="#SEC7">NEWLINES</a> |
<li><a name="TOC8" href="#SEC8">OPTIONS WITH DATA</a> | <li><a name="TOC8" href="#SEC8">OPTIONS COMPATIBILITY</a> |
<li><a name="TOC9" href="#SEC9">MATCHING ERRORS</a> | <li><a name="TOC9" href="#SEC9">OPTIONS WITH DATA</a> |
<li><a name="TOC10" href="#SEC10">DIAGNOSTICS</a> | <li><a name="TOC10" href="#SEC10">MATCHING ERRORS</a> |
<li><a name="TOC11" href="#SEC11">SEE ALSO</a> | <li><a name="TOC11" href="#SEC11">DIAGNOSTICS</a> |
<li><a name="TOC12" href="#SEC12">AUTHOR</a> | <li><a name="TOC12" href="#SEC12">SEE ALSO</a> |
<li><a name="TOC13" href="#SEC13">REVISION</a> | <li><a name="TOC13" href="#SEC13">AUTHOR</a> |
| <li><a name="TOC14" href="#SEC14">REVISION</a> |
</ul> |
</ul> |
<br><a name="SEC1" href="#TOC1">SYNOPSIS</a><br> |
<br><a name="SEC1" href="#TOC1">SYNOPSIS</a><br> |
<P> |
<P> |
Line 125 of these file types by running it with the <b>--help</
|
Line 126 of these file types by running it with the <b>--help</
|
appropriate support is not present, files are treated as plain text. The |
appropriate support is not present, files are treated as plain text. The |
standard input is always so treated. |
standard input is always so treated. |
</P> |
</P> |
<br><a name="SEC4" href="#TOC1">OPTIONS</a><br> | <br><a name="SEC4" href="#TOC1">BINARY FILES</a><br> |
<P> |
<P> |
|
By default, a file that contains a binary zero byte within the first 1024 bytes |
|
is identified as a binary file, and is processed specially. (GNU grep also |
|
identifies binary files in this manner.) See the <b>--binary-files</b> option |
|
for a means of changing the way binary files are handled. |
|
</P> |
|
<br><a name="SEC5" href="#TOC1">OPTIONS</a><br> |
|
<P> |
The order in which some of the options appear can affect the output. For |
The order in which some of the options appear can affect the output. For |
example, both the <b>-h</b> and <b>-l</b> options affect the printing of file |
example, both the <b>-h</b> and <b>-l</b> options affect the printing of file |
names. Whichever comes later in the command line will be the one that takes |
names. Whichever comes later in the command line will be the one that takes |
Line 149 of <i>number</i> is expected to be relatively small. H
|
Line 157 of <i>number</i> is expected to be relatively small. H
|
guarantees to have up to 8K of following text available for context output. |
guarantees to have up to 8K of following text available for context output. |
</P> |
</P> |
<P> |
<P> |
|
<b>-a</b>, <b>--text</b> |
|
Treat binary files as text. This is equivalent to |
|
<b>--binary-files</b>=<i>text</i>. |
|
</P> |
|
<P> |
<b>-B</b> <i>number</i>, <b>--before-context=</b><i>number</i> |
<b>-B</b> <i>number</i>, <b>--before-context=</b><i>number</i> |
Output <i>number</i> lines of context before each matching line. If filenames |
Output <i>number</i> lines of context before each matching line. If filenames |
and/or line numbers are being output, a hyphen separator is used instead of a |
and/or line numbers are being output, a hyphen separator is used instead of a |
Line 158 of <i>number</i> is expected to be relatively small. H
|
Line 171 of <i>number</i> is expected to be relatively small. H
|
guarantees to have up to 8K of preceding text available for context output. |
guarantees to have up to 8K of preceding text available for context output. |
</P> |
</P> |
<P> |
<P> |
|
<b>--binary-files=</b><i>word</i> |
|
Specify how binary files are to be processed. If the word is "binary" (the |
|
default), pattern matching is performed on binary files, but the only output is |
|
"Binary file <name> matches" when a match succeeds. If the word is "text", |
|
which is equivalent to the <b>-a</b> or <b>--text</b> option, binary files are |
|
processed in the same way as any other file. In this case, when a match |
|
succeeds, the output may be binary garbage, which can have nasty effects if |
|
sent to a terminal. If the word is "without-match", which is equivalent to the |
|
<b>-I</b> option, binary files are not processed at all; they are assumed not to |
|
be of interest. |
|
</P> |
|
<P> |
<b>--buffer-size=</b><i>number</i> |
<b>--buffer-size=</b><i>number</i> |
Set the parameter that controls how much memory is used for buffering files |
Set the parameter that controls how much memory is used for buffering files |
that are being scanned. |
that are being scanned. |
Line 269 each line of input. A data line is output if any of th
|
Line 294 each line of input. A data line is output if any of th
|
filename can be given as "-" to refer to the standard input. When <b>-f</b> is |
filename can be given as "-" to refer to the standard input. When <b>-f</b> is |
used, patterns specified on the command line using <b>-e</b> may also be |
used, patterns specified on the command line using <b>-e</b> may also be |
present; they are tested before the file's patterns. However, no other pattern |
present; they are tested before the file's patterns. However, no other pattern |
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 the names of paths |
is an overall maximum of 100 patterns. Trailing white space is removed from | to be searched. There is an overall maximum of 100 patterns. Trailing white |
each line, and blank lines are ignored. An empty file contains no patterns and | space is removed from each line, and blank lines are ignored. An empty file |
therefore matches nothing. See also the comments about multiple patterns versus | contains no patterns and therefore matches nothing. See also the comments about |
a single pattern with alternatives in the description of <b>-e</b> above. | multiple patterns versus a single pattern with alternatives in the description |
| of <b>-e</b> above. |
</P> |
</P> |
<P> |
<P> |
|
<b>--file-list</b>=<i>filename</i> |
|
Read a list of files to be searched from the given file, one per line. Trailing |
|
white space is removed from each line, and blank lines are ignored. These files |
|
are searched before any others that may be listed on the command line. The |
|
filename can be given as "-" to refer to the standard input. If <b>--file</b> |
|
and <b>--file-list</b> are both specified as "-", patterns are read first. This |
|
is useful only when the standard input is a terminal, from which further lines |
|
(the list of files) can be read after an end-of-file indication. |
|
</P> |
|
<P> |
<b>--file-offsets</b> |
<b>--file-offsets</b> |
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 |
offset from the start of the file and a length, separated by a comma. In this |
offset from the start of the file and a length, separated by a comma. In this |
Line 305 Output a help message, giving brief details of the com
|
Line 341 Output a help message, giving brief details of the com
|
type support, and then exit. |
type support, and then exit. |
</P> |
</P> |
<P> |
<P> |
|
<b>-I</b> |
|
Treat binary files as never matching. This is equivalent to |
|
<b>--binary-files</b>=<i>without-match</i>. |
|
</P> |
|
<P> |
<b>-i</b>, <b>--ignore-case</b> |
<b>-i</b>, <b>--ignore-case</b> |
Ignore upper/lower case distinctions during comparisons. |
Ignore upper/lower case distinctions during comparisons. |
</P> |
</P> |
Line 537 a line) and in addition, require them to match entire
|
Line 578 a line) and in addition, require them to match entire
|
equivalent to having ^ and $ characters at the start and end of each |
equivalent to having ^ and $ characters at the start and end of each |
alternative branch in every pattern. |
alternative branch in every pattern. |
</P> |
</P> |
<br><a name="SEC5" href="#TOC1">ENVIRONMENT VARIABLES</a><br> | <br><a name="SEC6" href="#TOC1">ENVIRONMENT VARIABLES</a><br> |
<P> |
<P> |
The environment variables <b>LC_ALL</b> and <b>LC_CTYPE</b> are examined, in that |
The environment variables <b>LC_ALL</b> and <b>LC_CTYPE</b> are examined, in that |
order, for a locale. The first one that is set is used. This can be overridden |
order, for a locale. The first one that is set is used. This can be overridden |
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 |
(usually the "C" locale) is used. |
(usually the "C" locale) is used. |
</P> |
</P> |
<br><a name="SEC6" href="#TOC1">NEWLINES</a><br> | <br><a name="SEC7" href="#TOC1">NEWLINES</a><br> |
<P> |
<P> |
The <b>-N</b> (<b>--newline</b>) option allows <b>pcregrep</b> to scan files with |
The <b>-N</b> (<b>--newline</b>) option allows <b>pcregrep</b> to scan files with |
different newline conventions from the default. However, the setting of this |
different newline conventions from the default. However, the setting of this |
Line 553 the standard error and output streams. It uses the str
|
Line 594 the standard error and output streams. It uses the str
|
<b>printf()</b> calls to indicate newlines, relying on the C I/O library to |
<b>printf()</b> calls to indicate newlines, relying on the C I/O library to |
convert this to an appropriate sequence if the output is sent to a file. |
convert this to an appropriate sequence if the output is sent to a file. |
</P> |
</P> |
<br><a name="SEC7" href="#TOC1">OPTIONS COMPATIBILITY</a><br> | <br><a name="SEC8" href="#TOC1">OPTIONS COMPATIBILITY</a><br> |
<P> |
<P> |
Many of the short and long forms of <b>pcregrep</b>'s options are the same |
Many of the short and long forms of <b>pcregrep</b>'s options are the same |
as in the GNU <b>grep</b> program (version 2.5.4). Any long option of the form | as in the GNU <b>grep</b> program. Any long option of the form |
<b>--xxx-regexp</b> (GNU terminology) is also available as <b>--xxx-regex</b> |
<b>--xxx-regexp</b> (GNU terminology) is also available as <b>--xxx-regex</b> |
(PCRE terminology). However, the <b>--file-offsets</b>, <b>--include-dir</b>, | (PCRE terminology). However, the <b>--file-list</b>, <b>--file-offsets</b>, |
<b>--line-offsets</b>, <b>--locale</b>, <b>--match-limit</b>, <b>-M</b>, | <b>--include-dir</b>, <b>--line-offsets</b>, <b>--locale</b>, <b>--match-limit</b>, |
<b>--multiline</b>, <b>-N</b>, <b>--newline</b>, <b>--recursion-limit</b>, | <b>-M</b>, <b>--multiline</b>, <b>-N</b>, <b>--newline</b>, |
<b>-u</b>, and <b>--utf-8</b> options are specific to <b>pcregrep</b>, as is the | <b>--recursion-limit</b>, <b>-u</b>, and <b>--utf-8</b> options are specific to |
use of the <b>--only-matching</b> option with a capturing parentheses number. | <b>pcregrep</b>, as is the use of the <b>--only-matching</b> option with a |
| capturing parentheses number. |
</P> |
</P> |
<P> |
<P> |
Although most of the common options work the same way, a few are different in |
Although most of the common options work the same way, a few are different in |
Line 571 for GNU <b>grep</b>, but a regular expression for <b>p
|
Line 613 for GNU <b>grep</b>, but a regular expression for <b>p
|
<b>-c</b> and <b>-l</b> options are given, GNU grep lists only file names, |
<b>-c</b> and <b>-l</b> options are given, GNU grep lists only file names, |
without counts, but <b>pcregrep</b> gives the counts. |
without counts, but <b>pcregrep</b> gives the counts. |
</P> |
</P> |
<br><a name="SEC8" href="#TOC1">OPTIONS WITH DATA</a><br> | <br><a name="SEC9" href="#TOC1">OPTIONS WITH DATA</a><br> |
<P> |
<P> |
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. |
If a short form option is used, the data may follow immediately, or (with one |
If a short form option is used, the data may follow immediately, or (with one |
Line 603 The exceptions to the above are the <b>--colour</b> (o
|
Line 645 The exceptions to the above are the <b>--colour</b> (o
|
options does have data, it must be given in the first form, using an equals |
options does have data, it must be given in the first form, using an equals |
character. Otherwise <b>pcregrep</b> will assume that it has no data. |
character. Otherwise <b>pcregrep</b> will assume that it has no data. |
</P> |
</P> |
<br><a name="SEC9" href="#TOC1">MATCHING ERRORS</a><br> | <br><a name="SEC10" href="#TOC1">MATCHING ERRORS</a><br> |
<P> |
<P> |
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 |
fail to match certain lines. Such patterns normally involve nested indefinite |
fail to match certain lines. Such patterns normally involve nested indefinite |
Line 619 resource limit; there is a second option called <b>--r
|
Line 661 resource limit; there is a second option called <b>--r
|
sets a limit on the amount of memory (usually stack) that is used (see the |
sets a limit on the amount of memory (usually stack) that is used (see the |
discussion of these options above). |
discussion of these options above). |
</P> |
</P> |
<br><a name="SEC10" href="#TOC1">DIAGNOSTICS</a><br> | <br><a name="SEC11" href="#TOC1">DIAGNOSTICS</a><br> |
<P> |
<P> |
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 |
for syntax errors, overlong lines, non-existent or inaccessible files (even if |
for syntax errors, overlong lines, non-existent or inaccessible files (even if |
Line 627 matches were found in other files) or too many matchin
|
Line 669 matches were found in other files) or too many matchin
|
<b>-s</b> option to suppress error messages about inaccessible files does not |
<b>-s</b> option to suppress error messages about inaccessible files does not |
affect the return code. |
affect the return code. |
</P> |
</P> |
<br><a name="SEC11" href="#TOC1">SEE ALSO</a><br> | <br><a name="SEC12" href="#TOC1">SEE ALSO</a><br> |
<P> |
<P> |
<b>pcrepattern</b>(3), <b>pcretest</b>(1). |
<b>pcrepattern</b>(3), <b>pcretest</b>(1). |
</P> |
</P> |
<br><a name="SEC12" href="#TOC1">AUTHOR</a><br> | <br><a name="SEC13" href="#TOC1">AUTHOR</a><br> |
<P> |
<P> |
Philip Hazel |
Philip Hazel |
<br> |
<br> |
Line 640 University Computing Service
|
Line 682 University Computing Service
|
Cambridge CB2 3QH, England. |
Cambridge CB2 3QH, England. |
<br> |
<br> |
</P> |
</P> |
<br><a name="SEC13" href="#TOC1">REVISION</a><br> | <br><a name="SEC14" href="#TOC1">REVISION</a><br> |
<P> |
<P> |
Last updated: 06 September 2011 | Last updated: 04 March 2012 |
<br> |
<br> |
Copyright © 1997-2011 University of Cambridge. | Copyright © 1997-2012 University of Cambridge. |
<br> |
<br> |
<p> |
<p> |
Return to the <a href="index.html">PCRE index page</a>. |
Return to the <a href="index.html">PCRE index page</a>. |