version 1.1, 2012/02/21 23:05:51
|
version 1.1.1.2, 2012/10/09 09:19:17
|
Line 98 SUPPORT FOR COMPRESSED FILES
|
Line 98 SUPPORT FOR COMPRESSED FILES
|
so treated. |
so treated. |
|
|
|
|
|
BINARY FILES |
|
|
|
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 |
|
--binary-files option for a means of changing the way binary files are |
|
handled. |
|
|
|
|
OPTIONS |
OPTIONS |
|
|
The order in which some of the options appear can affect the output. |
The order in which some of the options appear can affect the output. |
Line 121 OPTIONS
|
Line 130 OPTIONS
|
pcregrep guarantees to have up to 8K of following text avail- |
pcregrep guarantees to have up to 8K of following text avail- |
able for context output. |
able for context output. |
|
|
|
-a, --text |
|
Treat binary files as text. This is equivalent to --binary- |
|
files=text. |
|
|
-B number, --before-context=number |
-B number, --before-context=number |
Output number lines of context before each matching line. If | Output number lines of context before each matching line. If |
filenames and/or line numbers are being output, a hyphen sep- |
filenames and/or line numbers are being output, a hyphen sep- |
arator is used instead of a colon for the context lines. A | arator is used instead of a colon for the context lines. A |
line containing "--" is output between each group of lines, | line containing "--" is output between each group of lines, |
unless they are in fact contiguous in the input file. The | unless they are in fact contiguous in the input file. The |
value of number is expected to be relatively small. However, | value of number is expected to be relatively small. However, |
pcregrep guarantees to have up to 8K of preceding text avail- |
pcregrep guarantees to have up to 8K of preceding text avail- |
able for context output. |
able for context output. |
|
|
|
--binary-files=word |
|
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 -a or --text 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 -I |
|
option, binary files are not processed at all; they are |
|
assumed not to be of interest. |
|
|
--buffer-size=number |
--buffer-size=number |
Set the parameter that controls how much memory is used for | Set the parameter that controls how much memory is used for |
buffering files that are being scanned. |
buffering files that are being scanned. |
|
|
-C number, --context=number |
-C number, --context=number |
Output number lines of context both before and after each | Output number lines of context both before and after each |
matching line. This is equivalent to setting both -A and -B | matching line. This is equivalent to setting both -A and -B |
to the same value. |
to the same value. |
|
|
-c, --count |
-c, --count |
Do not output individual lines from the files that are being | Do not output individual lines from the files that are being |
scanned; instead output the number of lines that would other- |
scanned; instead output the number of lines that would other- |
wise have been shown. If no lines are selected, the number | wise have been shown. If no lines are selected, the number |
zero is output. If several files are are being scanned, a | zero is output. If several files are are being scanned, a |
count is output for each of them. However, if the --files- | count is output for each of them. However, if the --files- |
with-matches option is also used, only those files whose | with-matches option is also used, only those files whose |
counts are greater than zero are listed. When -c is used, the |
counts are greater than zero are listed. When -c is used, the |
-A, -B, and -C options are ignored. |
-A, -B, and -C options are ignored. |
|
|
--colour, --color |
--colour, --color |
If this option is given without any data, it is equivalent to |
If this option is given without any data, it is equivalent to |
"--colour=auto". If data is required, it must be given in | "--colour=auto". If data is required, it must be given in |
the same shell item, separated by an equals sign. |
the same shell item, separated by an equals sign. |
|
|
--colour=value, --color=value |
--colour=value, --color=value |
This option specifies under what circumstances the parts of a |
This option specifies under what circumstances the parts of a |
line that matched a pattern should be coloured in the output. |
line that matched a pattern should be coloured in the output. |
By default, the output is not coloured. The value (which is | By default, the output is not coloured. The value (which is |
optional, see above) may be "never", "always", or "auto". In | optional, see above) may be "never", "always", or "auto". In |
the latter case, colouring happens only if the standard out- | the latter case, colouring happens only if the standard out- |
put is connected to a terminal. More resources are used when | put is connected to a terminal. More resources are used when |
colouring is enabled, because pcregrep has to search for all | colouring is enabled, because pcregrep has to search for all |
possible matches in a line, not just one, in order to colour | possible matches in a line, not just one, in order to colour |
them all. |
them all. |
|
|
The colour that is used can be specified by setting the envi- |
The colour that is used can be specified by setting the envi- |
ronment variable PCREGREP_COLOUR or PCREGREP_COLOR. The value |
ronment variable PCREGREP_COLOUR or PCREGREP_COLOR. The value |
of this variable should be a string of two numbers, separated |
of this variable should be a string of two numbers, separated |
by a semicolon. They are copied directly into the control | by a semicolon. They are copied directly into the control |
string for setting colour on a terminal, so it is your | string for setting colour on a terminal, so it is your |
responsibility to ensure that they make sense. If neither of | responsibility to ensure that they make sense. If neither of |
the environment variables is set, the default is "1;31", | the environment variables is set, the default is "1;31", |
which gives red. |
which gives red. |
|
|
-D action, --devices=action |
-D action, --devices=action |
If an input path is not a regular file or a directory, | If an input path is not a regular file or a directory, |
"action" specifies how it is to be processed. Valid values | "action" specifies how it is to be processed. Valid values |
are "read" (the default) or "skip" (silently skip the path). |
are "read" (the default) or "skip" (silently skip the path). |
|
|
-d action, --directories=action |
-d action, --directories=action |
If an input path is a directory, "action" specifies how it is |
If an input path is a directory, "action" specifies how it is |
to be processed. Valid values are "read" (the default), | to be processed. Valid values are "read" (the default), |
"recurse" (equivalent to the -r option), or "skip" (silently | "recurse" (equivalent to the -r option), or "skip" (silently |
skip the path). In the default case, directories are read as | skip the path). In the default case, directories are read as |
if they were ordinary files. In some operating systems the | if they were ordinary files. In some operating systems the |
effect of reading a directory like this is an immediate end- | effect of reading a directory like this is an immediate end- |
of-file. |
of-file. |
|
|
-e pattern, --regex=pattern, --regexp=pattern |
-e pattern, --regex=pattern, --regexp=pattern |
Specify a pattern to be matched. This option can be used mul- |
Specify a pattern to be matched. This option can be used mul- |
tiple times in order to specify several patterns. It can also |
tiple times in order to specify several patterns. It can also |
be used as a way of specifying a single pattern that starts | be used as a way of specifying a single pattern that starts |
with a hyphen. When -e is used, no argument pattern is taken | with a hyphen. When -e is used, no argument pattern is taken |
from the command line; all arguments are treated as file | from the command line; all arguments are treated as file |
names. There is an overall maximum of 100 patterns. They are | names. There is an overall maximum of 100 patterns. They are |
applied to each line in the order in which they are defined | applied to each line in the order in which they are defined |
until one matches (or fails to match if -v is used). If -f is |
until one matches (or fails to match if -v is used). If -f is |
used with -e, the command line patterns are matched first, | used with -e, the command line patterns are matched first, |
followed by the patterns from the file, independent of the | followed by the patterns from the file, independent of the |
order in which these options are specified. Note that multi- | order in which these options are specified. Note that multi- |
ple use of -e is not the same as a single pattern with alter- |
ple use of -e is not the same as a single pattern with alter- |
natives. For example, X|Y finds the first character in a line |
natives. For example, X|Y finds the first character in a line |
that is X or Y, whereas if the two patterns are given sepa- | that is X or Y, whereas if the two patterns are given sepa- |
rately, pcregrep finds X if it is present, even if it follows |
rately, pcregrep finds X if it is present, even if it follows |
Y in the line. It finds Y only if there is no X in the line. | Y in the line. It finds Y only if there is no X in the line. |
This really matters only if you are using -o to show the | This really matters only if you are using -o to show the |
part(s) of the line that matched. |
part(s) of the line that matched. |
|
|
--exclude=pattern |
--exclude=pattern |
When pcregrep is searching the files in a directory as a con- |
When pcregrep is searching the files in a directory as a con- |
sequence of the -r (recursive search) option, any regular | sequence of the -r (recursive search) option, any regular |
files whose names match the pattern are excluded. Subdirecto- |
files whose names match the pattern are excluded. Subdirecto- |
ries are not excluded by this option; they are searched | ries are not excluded by this option; they are searched |
recursively, subject to the --exclude-dir and --include_dir | recursively, subject to the --exclude-dir and --include_dir |
options. The pattern is a PCRE regular expression, and is | options. The pattern is a PCRE regular expression, and is |
matched against the final component of the file name (not the |
matched against the final component of the file name (not the |
entire path). If a file name matches both --include and | entire path). If a file name matches both --include and |
--exclude, it is excluded. There is no short form for this | --exclude, it is excluded. There is no short form for this |
option. |
option. |
|
|
--exclude-dir=pattern |
--exclude-dir=pattern |
When pcregrep is searching the contents of a directory as a | When pcregrep is searching the contents of a directory as a |
consequence of the -r (recursive search) option, any subdi- | consequence of the -r (recursive search) option, any subdi- |
rectories whose names match the pattern are excluded. (Note | rectories whose names match the pattern are excluded. (Note |
that the --exclude option does not affect subdirectories.) | that the --exclude option does not affect subdirectories.) |
The pattern is a PCRE regular expression, and is matched | The pattern is a PCRE regular expression, and is matched |
against the final component of the name (not the entire | against the final component of the name (not the entire |
path). If a subdirectory name matches both --include-dir and | path). If a subdirectory name matches both --include-dir and |
--exclude-dir, it is excluded. There is no short form for | --exclude-dir, it is excluded. There is no short form for |
this option. |
this option. |
|
|
-F, --fixed-strings |
-F, --fixed-strings |
Interpret each pattern as a list of fixed strings, separated | Interpret each pattern as a list of fixed strings, separated |
by newlines, instead of as a regular expression. The -w | by newlines, instead of as a regular expression. The -w |
(match as a word) and -x (match whole line) options can be | (match as a word) and -x (match whole line) options can be |
used with -F. They apply to each of the fixed strings. A line |
used with -F. They apply to each of the fixed strings. A line |
is selected if any of the fixed strings are found in it (sub- |
is selected if any of the fixed strings are found in it (sub- |
ject to -w or -x, if present). |
ject to -w or -x, if present). |
|
|
-f filename, --file=filename |
-f filename, --file=filename |
Read a number of patterns from the file, one per line, and | Read a number of patterns from the file, one per line, and |
match them against each line of input. A data line is output | match them against each line of input. A data line is output |
if any of the patterns match it. The filename can be given as |
if any of the patterns match it. The filename can be given as |
"-" to refer to the standard input. When -f is used, patterns |
"-" to refer to the standard input. When -f is used, patterns |
specified on the command line using -e may also be present; | specified on the command line using -e may also be present; |
they are tested before the file's patterns. However, no other |
they are tested before the file's patterns. However, no other |
pattern is taken from the command line; all arguments are | pattern is taken from the command line; all arguments are |
treated as file names. There is an overall maximum of 100 | treated as the names of paths to be searched. There is an |
patterns. Trailing white space is removed from each line, and | overall maximum of 100 patterns. Trailing white space is |
blank lines are ignored. An empty file contains no patterns | removed from each line, and blank lines are ignored. An empty |
and therefore matches nothing. See also the comments about | file contains no patterns and therefore matches nothing. See |
multiple patterns versus a single pattern with alternatives | also the comments about multiple patterns versus a single |
in the description of -e above. | pattern with alternatives in the description of -e above. |
|
|
|
--file-list=filename |
|
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 --file |
|
and --file-list are both specified as "-", patterns are read |
|
first. This is useful only when the standard input is a ter- |
|
minal, from which further lines (the list of files) can be |
|
read after an end-of-file indication. |
|
|
--file-offsets |
--file-offsets |
Instead of showing lines or parts of lines that match, show | Instead of showing lines or parts of lines that match, show |
each match as an offset from the start of the file and a | each match as an offset from the start of the file and a |
length, separated by a comma. In this mode, no context is | length, separated by a comma. In this mode, no context is |
shown. That is, the -A, -B, and -C options are ignored. If | shown. That is, the -A, -B, and -C options are ignored. If |
there is more than one match in a line, each of them is shown |
there is more than one match in a line, each of them is shown |
separately. This option is mutually exclusive with --line- | separately. This option is mutually exclusive with --line- |
offsets and --only-matching. |
offsets and --only-matching. |
|
|
-H, --with-filename |
-H, --with-filename |
Force the inclusion of the filename at the start of output | Force the inclusion of the filename at the start of output |
lines when searching a single file. By default, the filename | lines when searching a single file. By default, the filename |
is not shown in this case. For matching lines, the filename | is not shown in this case. For matching lines, the filename |
is followed by a colon; for context lines, a hyphen separator |
is followed by a colon; for context lines, a hyphen separator |
is used. If a line number is also being output, it follows | is used. If a line number is also being output, it follows |
the file name. |
the file name. |
|
|
-h, --no-filename |
-h, --no-filename |
Suppress the output filenames when searching multiple files. | Suppress the output filenames when searching multiple files. |
By default, filenames are shown when multiple files are | By default, filenames are shown when multiple files are |
searched. For matching lines, the filename is followed by a | searched. For matching lines, the filename is followed by a |
colon; for context lines, a hyphen separator is used. If a | colon; for context lines, a hyphen separator is used. If a |
line number is also being output, it follows the file name. |
line number is also being output, it follows the file name. |
|
|
--help Output a help message, giving brief details of the command | --help Output a help message, giving brief details of the command |
options and file type support, and then exit. |
options and file type support, and then exit. |
|
|
|
-I Treat binary files as never matching. This is equivalent to |
|
--binary-files=without-match. |
|
|
-i, --ignore-case |
-i, --ignore-case |
Ignore upper/lower case distinctions during comparisons. |
Ignore upper/lower case distinctions during comparisons. |
|
|
Line 540 NEWLINES
|
Line 580 NEWLINES
|
OPTIONS COMPATIBILITY |
OPTIONS COMPATIBILITY |
|
|
Many of the short and long forms of pcregrep's options are the same as |
Many of the short and long forms of pcregrep's options are the same as |
in the GNU grep program (version 2.5.4). Any long option of the form | in the GNU grep program. Any long option of the form --xxx-regexp (GNU |
--xxx-regexp (GNU terminology) is also available as --xxx-regex (PCRE | terminology) is also available as --xxx-regex (PCRE terminology). How- |
terminology). However, the --file-offsets, --include-dir, --line-off- | ever, the --file-list, --file-offsets, --include-dir, --line-offsets, |
sets, --locale, --match-limit, -M, --multiline, -N, --newline, --recur- | --locale, --match-limit, -M, --multiline, -N, --newline, --recursion- |
sion-limit, -u, and --utf-8 options are specific to pcregrep, as is the | limit, -u, and --utf-8 options are specific to pcregrep, as is the use |
use of the --only-matching option with a capturing parentheses number. | of the --only-matching option with a capturing parentheses number. |
|
|
Although most of the common options work the same way, a few are dif- |
Although most of the common options work the same way, a few are dif- |
ferent in pcregrep. For example, the --include option's argument is a |
ferent in pcregrep. For example, the --include option's argument is a |
Line 626 AUTHOR
|
Line 666 AUTHOR
|
|
|
REVISION |
REVISION |
|
|
Last updated: 06 September 2011 | Last updated: 04 March 2012 |
Copyright (c) 1997-2011 University of Cambridge. | Copyright (c) 1997-2012 University of Cambridge. |