| 44 |
dard output, and if there is more than one file, the file name is out- |
dard output, and if there is more than one file, the file name is out- |
| 45 |
put at the start of each line. However, there are options that can |
put at the start of each line. However, there are options that can |
| 46 |
change how pcregrep behaves. In particular, the -M option makes it pos- |
change how pcregrep behaves. In particular, the -M option makes it pos- |
| 47 |
sible to search for patterns that span line boundaries. |
sible to search for patterns that span line boundaries. What defines a |
| 48 |
|
line boundary is controlled by the -N (--newline) option. |
| 49 |
|
|
| 50 |
Patterns are limited to 8K or BUFSIZ characters, whichever is the |
Patterns are limited to 8K or BUFSIZ characters, whichever is the |
| 51 |
greater. BUFSIZ is defined in <stdio.h>. |
greater. BUFSIZ is defined in <stdio.h>. |
| 52 |
|
|
| 53 |
If the LC_ALL or LC_CTYPE environment variable is set, pcregrep uses |
If the LC_ALL or LC_CTYPE environment variable is set, pcregrep uses |
| 54 |
the value to set a locale when calling the PCRE library. The --locale |
the value to set a locale when calling the PCRE library. The --locale |
| 55 |
option can be used to override this. |
option can be used to override this. |
| 56 |
|
|
| 57 |
|
|
| 58 |
OPTIONS |
OPTIONS |
| 59 |
|
|
| 60 |
-- This terminate the list of options. It is useful if the next |
-- This terminate the list of options. It is useful if the next |
| 61 |
item on the command line starts with a hyphen but is not an |
item on the command line starts with a hyphen but is not an |
| 62 |
option. This allows for the processing of patterns and file- |
option. This allows for the processing of patterns and file- |
| 63 |
names that start with hyphens. |
names that start with hyphens. |
| 64 |
|
|
| 65 |
-A number, --after-context=number |
-A number, --after-context=number |
| 66 |
Output number lines of context after each matching line. If |
Output number lines of context after each matching line. If |
| 67 |
filenames and/or line numbers are being output, a hyphen sep- |
filenames and/or line numbers are being output, a hyphen sep- |
| 68 |
arator is used instead of a colon for the context lines. A |
arator is used instead of a colon for the context lines. A |
| 69 |
line containing "--" is output between each group of lines, |
line containing "--" is output between each group of lines, |
| 70 |
unless they are in fact contiguous in the input file. The |
unless they are in fact contiguous in the input file. The |
| 71 |
value of number is expected to be relatively small. However, |
value of number is expected to be relatively small. However, |
| 72 |
pcregrep guarantees to have up to 8K of following text avail- |
pcregrep guarantees to have up to 8K of following text avail- |
| 73 |
able for context output. |
able for context output. |
| 74 |
|
|
| 75 |
-B number, --before-context=number |
-B number, --before-context=number |
| 76 |
Output number lines of context before each matching line. If |
Output number lines of context before each matching line. If |
| 77 |
filenames and/or line numbers are being output, a hyphen sep- |
filenames and/or line numbers are being output, a hyphen sep- |
| 78 |
arator is used instead of a colon for the context lines. A |
arator is used instead of a colon for the context lines. A |
| 79 |
line containing "--" is output between each group of lines, |
line containing "--" is output between each group of lines, |
| 80 |
unless they are in fact contiguous in the input file. The |
unless they are in fact contiguous in the input file. The |
| 81 |
value of number is expected to be relatively small. However, |
value of number is expected to be relatively small. However, |
| 82 |
pcregrep guarantees to have up to 8K of preceding text avail- |
pcregrep guarantees to have up to 8K of preceding text avail- |
| 83 |
able for context output. |
able for context output. |
| 84 |
|
|
| 85 |
-C number, --context=number |
-C number, --context=number |
| 86 |
Output number lines of context both before and after each |
Output number lines of context both before and after each |
| 87 |
matching line. This is equivalent to setting both -A and -B |
matching line. This is equivalent to setting both -A and -B |
| 88 |
to the same value. |
to the same value. |
| 89 |
|
|
| 90 |
-c, --count |
-c, --count |
| 91 |
Do not output individual lines; instead just output a count |
Do not output individual lines; instead just output a count |
| 92 |
of the number of lines that would otherwise have been output. |
of the number of lines that would otherwise have been output. |
| 93 |
If several files are given, a count is output for each of |
If several files are given, a count is output for each of |
| 94 |
them. In this mode, the -A, -B, and -C options are ignored. |
them. In this mode, the -A, -B, and -C options are ignored. |
| 95 |
|
|
| 96 |
--colour, --color |
--colour, --color |
| 97 |
If this option is given without any data, it is equivalent to |
If this option is given without any data, it is equivalent to |
| 98 |
"--colour=auto". If data is required, it must be given in |
"--colour=auto". If data is required, it must be given in |
| 99 |
the same shell item, separated by an equals sign. |
the same shell item, separated by an equals sign. |
| 100 |
|
|
| 101 |
--colour=value, --color=value |
--colour=value, --color=value |
| 102 |
This option specifies under what circumstances the part of a |
This option specifies under what circumstances the part of a |
| 103 |
line that matched a pattern should be coloured in the output. |
line that matched a pattern should be coloured in the output. |
| 104 |
The value may be "never" (the default), "always", or "auto". |
The value may be "never" (the default), "always", or "auto". |
| 105 |
In the latter case, colouring happens only if the standard |
In the latter case, colouring happens only if the standard |
| 106 |
output is connected to a terminal. The colour can be speci- |
output is connected to a terminal. The colour can be speci- |
| 107 |
fied by setting the environment variable PCREGREP_COLOUR or |
fied by setting the environment variable PCREGREP_COLOUR or |
| 108 |
PCREGREP_COLOR. The value of this variable should be a string |
PCREGREP_COLOR. The value of this variable should be a string |
| 109 |
of two numbers, separated by a semicolon. They are copied |
of two numbers, separated by a semicolon. They are copied |
| 110 |
directly into the control string for setting colour on a ter- |
directly into the control string for setting colour on a ter- |
| 111 |
minal, so it is your responsibility to ensure that they make |
minal, so it is your responsibility to ensure that they make |
| 112 |
sense. If neither of the environment variables is set, the |
sense. If neither of the environment variables is set, the |
| 113 |
default is "1;31", which gives red. |
default is "1;31", which gives red. |
| 114 |
|
|
| 115 |
-D action, --devices=action |
-D action, --devices=action |
| 116 |
If an input path is not a regular file or a directory, |
If an input path is not a regular file or a directory, |
| 117 |
"action" specifies how it is to be processed. Valid values |
"action" specifies how it is to be processed. Valid values |
| 118 |
are "read" (the default) or "skip" (silently skip the path). |
are "read" (the default) or "skip" (silently skip the path). |
| 119 |
|
|
| 120 |
-d action, --directories=action |
-d action, --directories=action |
| 121 |
If an input path is a directory, "action" specifies how it is |
If an input path is a directory, "action" specifies how it is |
| 122 |
to be processed. Valid values are "read" (the default), |
to be processed. Valid values are "read" (the default), |
| 123 |
"recurse" (equivalent to the -r option), or "skip" (silently |
"recurse" (equivalent to the -r option), or "skip" (silently |
| 124 |
skip the path). In the default case, directories are read as |
skip the path). In the default case, directories are read as |
| 125 |
if they were ordinary files. In some operating systems the |
if they were ordinary files. In some operating systems the |
| 126 |
effect of reading a directory like this is an immediate end- |
effect of reading a directory like this is an immediate end- |
| 127 |
of-file. |
of-file. |
| 128 |
|
|
| 129 |
-e pattern, --regex=pattern, |
-e pattern, --regex=pattern, |
| 130 |
--regexp=pattern Specify a pattern to be matched. This option |
--regexp=pattern Specify a pattern to be matched. This option |
| 131 |
can be used multiple times in order to specify several pat- |
can be used multiple times in order to specify several pat- |
| 132 |
terns. It can also be used as a way of specifying a single |
terns. It can also be used as a way of specifying a single |
| 133 |
pattern that starts with a hyphen. When -e is used, no argu- |
pattern that starts with a hyphen. When -e is used, no argu- |
| 134 |
ment pattern is taken from the command line; all arguments |
ment pattern is taken from the command line; all arguments |
| 135 |
are treated as file names. There is an overall maximum of 100 |
are treated as file names. There is an overall maximum of 100 |
| 136 |
patterns. They are applied to each line in the order in which |
patterns. They are applied to each line in the order in which |
| 137 |
they are defined until one matches (or fails to match if -v |
they are defined until one matches (or fails to match if -v |
| 138 |
is used). If -f is used with -e, the command line patterns |
is used). If -f is used with -e, the command line patterns |
| 139 |
are matched first, followed by the patterns from the file, |
are matched first, followed by the patterns from the file, |
| 140 |
independent of the order in which these options are speci- |
independent of the order in which these options are speci- |
| 141 |
fied. Note that multiple use of -e is not the same as a sin- |
fied. Note that multiple use of -e is not the same as a sin- |
| 142 |
gle pattern with alternatives. For example, X|Y finds the |
gle pattern with alternatives. For example, X|Y finds the |
| 143 |
first character in a line that is X or Y, whereas if the two |
first character in a line that is X or Y, whereas if the two |
| 144 |
patterns are given separately, pcregrep finds X if it is |
patterns are given separately, pcregrep finds X if it is |
| 145 |
present, even if it follows Y in the line. It finds Y only if |
present, even if it follows Y in the line. It finds Y only if |
| 146 |
there is no X in the line. This really matters only if you |
there is no X in the line. This really matters only if you |
| 147 |
are using -o to show the portion of the line that matched. |
are using -o to show the portion of the line that matched. |
| 148 |
|
|
| 149 |
--exclude=pattern |
--exclude=pattern |
| 150 |
When pcregrep is searching the files in a directory as a con- |
When pcregrep is searching the files in a directory as a con- |
| 151 |
sequence of the -r (recursive search) option, any files whose |
sequence of the -r (recursive search) option, any files whose |
| 152 |
names match the pattern are excluded. The pattern is a PCRE |
names match the pattern are excluded. The pattern is a PCRE |
| 153 |
regular expression. If a file name matches both --include and |
regular expression. If a file name matches both --include and |
| 154 |
--exclude, it is excluded. There is no short form for this |
--exclude, it is excluded. There is no short form for this |
| 155 |
option. |
option. |
| 156 |
|
|
| 157 |
-F, --fixed-strings |
-F, --fixed-strings |
| 158 |
Interpret each pattern as a list of fixed strings, separated |
Interpret each pattern as a list of fixed strings, separated |
| 159 |
by newlines, instead of as a regular expression. The -w |
by newlines, instead of as a regular expression. The -w |
| 160 |
(match as a word) and -x (match whole line) options can be |
(match as a word) and -x (match whole line) options can be |
| 161 |
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 |
| 162 |
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- |
| 163 |
ject to -w or -x, if present). |
ject to -w or -x, if present). |
| 164 |
|
|
| 165 |
-f filename, --file=filename |
-f filename, --file=filename |
| 166 |
Read a number of patterns from the file, one per line, and |
Read a number of patterns from the file, one per line, and |
| 167 |
match them against each line of input. A data line is output |
match them against each line of input. A data line is output |
| 168 |
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 |
| 169 |
"-" to refer to the standard input. When -f is used, patterns |
"-" to refer to the standard input. When -f is used, patterns |
| 170 |
specified on the command line using -e may also be present; |
specified on the command line using -e may also be present; |
| 171 |
they are tested before the file's patterns. However, no other |
they are tested before the file's patterns. However, no other |
| 172 |
pattern is taken from the command line; all arguments are |
pattern is taken from the command line; all arguments are |
| 173 |
treated as file names. There is an overall maximum of 100 |
treated as file names. There is an overall maximum of 100 |
| 174 |
patterns. Trailing white space is removed from each line, and |
patterns. Trailing white space is removed from each line, and |
| 175 |
blank lines are ignored. An empty file contains no patterns |
blank lines are ignored. An empty file contains no patterns |
| 176 |
and therefore matches nothing. |
and therefore matches nothing. |
| 177 |
|
|
| 178 |
-H, --with-filename |
-H, --with-filename |
| 179 |
Force the inclusion of the filename at the start of output |
Force the inclusion of the filename at the start of output |
| 180 |
lines when searching a single file. By default, the filename |
lines when searching a single file. By default, the filename |
| 181 |
is not shown in this case. For matching lines, the filename |
is not shown in this case. For matching lines, the filename |
| 182 |
is followed by a colon and a space; for context lines, a |
is followed by a colon and a space; for context lines, a |
| 183 |
hyphen separator is used. If a line number is also being out- |
hyphen separator is used. If a line number is also being out- |
| 184 |
put, it follows the file name without a space. |
put, it follows the file name without a space. |
| 185 |
|
|
| 186 |
-h, --no-filename |
-h, --no-filename |
| 187 |
Suppress the output filenames when searching multiple files. |
Suppress the output filenames when searching multiple files. |
| 188 |
By default, filenames are shown when multiple files are |
By default, filenames are shown when multiple files are |
| 189 |
searched. For matching lines, the filename is followed by a |
searched. For matching lines, the filename is followed by a |
| 190 |
colon and a space; for context lines, a hyphen separator is |
colon and a space; for context lines, a hyphen separator is |
| 191 |
used. If a line number is also being output, it follows the |
used. If a line number is also being output, it follows the |
| 192 |
file name without a space. |
file name without a space. |
| 193 |
|
|
| 194 |
--help Output a brief help message and exit. |
--help Output a brief help message and exit. |
| 198 |
|
|
| 199 |
--include=pattern |
--include=pattern |
| 200 |
When pcregrep is searching the files in a directory as a con- |
When pcregrep is searching the files in a directory as a con- |
| 201 |
sequence of the -r (recursive search) option, only those |
sequence of the -r (recursive search) option, only those |
| 202 |
files whose names match the pattern are included. The pattern |
files whose names match the pattern are included. The pattern |
| 203 |
is a PCRE regular expression. If a file name matches both |
is a PCRE regular expression. If a file name matches both |
| 204 |
--include and --exclude, it is excluded. There is no short |
--include and --exclude, it is excluded. There is no short |
| 205 |
form for this option. |
form for this option. |
| 206 |
|
|
| 207 |
-L, --files-without-match |
-L, --files-without-match |
| 208 |
Instead of outputting lines from the files, just output the |
Instead of outputting lines from the files, just output the |
| 209 |
names of the files that do not contain any lines that would |
names of the files that do not contain any lines that would |
| 210 |
have been output. Each file name is output once, on a sepa- |
have been output. Each file name is output once, on a sepa- |
| 211 |
rate line. |
rate line. |
| 212 |
|
|
| 213 |
-l, --files-with-matches |
-l, --files-with-matches |
| 214 |
Instead of outputting lines from the files, just output the |
Instead of outputting lines from the files, just output the |
| 215 |
names of the files containing lines that would have been out- |
names of the files containing lines that would have been out- |
| 216 |
put. Each file name is output once, on a separate line. |
put. Each file name is output once, on a separate line. |
| 217 |
Searching stops as soon as a matching line is found in a |
Searching stops as soon as a matching line is found in a |
| 218 |
file. |
file. |
| 219 |
|
|
| 220 |
--label=name |
--label=name |
| 223 |
input)" is used. There is no short form for this option. |
input)" is used. There is no short form for this option. |
| 224 |
|
|
| 225 |
--locale=locale-name |
--locale=locale-name |
| 226 |
This option specifies a locale to be used for pattern match- |
This option specifies a locale to be used for pattern match- |
| 227 |
ing. It overrides the value in the LC_ALL or LC_CTYPE envi- |
ing. It overrides the value in the LC_ALL or LC_CTYPE envi- |
| 228 |
ronment variables. If no locale is specified, the PCRE |
ronment variables. If no locale is specified, the PCRE |
| 229 |
library's default (usually the "C" locale) is used. There is |
library's default (usually the "C" locale) is used. There is |
| 230 |
no short form for this option. |
no short form for this option. |
| 231 |
|
|
| 232 |
-M, --multiline |
-M, --multiline |
| 233 |
Allow patterns to match more than one line. When this option |
Allow patterns to match more than one line. When this option |
| 234 |
is given, patterns may usefully contain literal newline char- |
is given, patterns may usefully contain literal newline char- |
| 235 |
acters and internal occurrences of ^ and $ characters. The |
acters and internal occurrences of ^ and $ characters. The |
| 236 |
output for any one match may consist of more than one line. |
output for any one match may consist of more than one line. |
| 237 |
When this option is set, the PCRE library is called in "mul- |
When this option is set, the PCRE library is called in "mul- |
| 238 |
tiline" mode. There is a limit to the number of lines that |
tiline" mode. There is a limit to the number of lines that |
| 239 |
can be matched, imposed by the way that pcregrep buffers the |
can be matched, imposed by the way that pcregrep buffers the |
| 240 |
input file as it scans it. However, pcregrep ensures that at |
input file as it scans it. However, pcregrep ensures that at |
| 241 |
least 8K characters or the rest of the document (whichever is |
least 8K characters or the rest of the document (whichever is |
| 242 |
the shorter) are available for forward matching, and simi- |
the shorter) are available for forward matching, and simi- |
| 243 |
larly the previous 8K characters (or all the previous charac- |
larly the previous 8K characters (or all the previous charac- |
| 244 |
ters, if fewer than 8K) are guaranteed to be available for |
ters, if fewer than 8K) are guaranteed to be available for |
| 245 |
lookbehind assertions. |
lookbehind assertions. |
| 246 |
|
|
| 247 |
|
-N newline-type, --newline=newline-type |
| 248 |
|
The PCRE library supports three different character sequences |
| 249 |
|
for indicating the ends of lines. They are the single-charac- |
| 250 |
|
ter sequences CR (carriage return) and LF (linefeed), and the |
| 251 |
|
two-character sequence CR, LF. When the library is built, a |
| 252 |
|
default line-ending sequence is specified. This is normally |
| 253 |
|
the standard sequence for the operating system. Unless other- |
| 254 |
|
wise specified by this option, pcregrep uses the default. The |
| 255 |
|
possible values for this option are CR, LF, or CRLF. This |
| 256 |
|
makes it possible to use pcregrep on files that have come |
| 257 |
|
from other environments without having to modify their line |
| 258 |
|
endings. If the data that is being scanned does not agree |
| 259 |
|
with the convention set by this option, pcregrep may behave |
| 260 |
|
in strange ways. |
| 261 |
|
|
| 262 |
-n, --line-number |
-n, --line-number |
| 263 |
Precede each output line by its line number in the file, fol- |
Precede each output line by its line number in the file, fol- |
| 264 |
lowed by a colon and a space for matching lines or a hyphen |
lowed by a colon and a space for matching lines or a hyphen |
| 265 |
and a space for context lines. If the filename is also being |
and a space for context lines. If the filename is also being |
| 266 |
output, it precedes the line number. |
output, it precedes the line number. |
| 267 |
|
|
| 268 |
-o, --only-matching |
-o, --only-matching |
| 269 |
Show only the part of the line that matched a pattern. In |
Show only the part of the line that matched a pattern. In |
| 270 |
this mode, no context is shown. That is, the -A, -B, and -C |
this mode, no context is shown. That is, the -A, -B, and -C |
| 271 |
options are ignored. |
options are ignored. |
| 272 |
|
|
| 273 |
-q, --quiet |
-q, --quiet |
| 274 |
Work quietly, that is, display nothing except error messages. |
Work quietly, that is, display nothing except error messages. |
| 275 |
The exit status indicates whether or not any matches were |
The exit status indicates whether or not any matches were |
| 276 |
found. |
found. |
| 277 |
|
|
| 278 |
-r, --recursive |
-r, --recursive |
| 279 |
If any given path is a directory, recursively scan the files |
If any given path is a directory, recursively scan the files |
| 280 |
it contains, taking note of any --include and --exclude set- |
it contains, taking note of any --include and --exclude set- |
| 281 |
tings. By default, a directory is read as a normal file; in |
tings. By default, a directory is read as a normal file; in |
| 282 |
some operating systems this gives an immediate end-of-file. |
some operating systems this gives an immediate end-of-file. |
| 283 |
This option is a shorthand for setting the -d option to |
This option is a shorthand for setting the -d option to |
| 284 |
"recurse". |
"recurse". |
| 285 |
|
|
| 286 |
-s, --no-messages |
-s, --no-messages |
| 287 |
Suppress error messages about non-existent or unreadable |
Suppress error messages about non-existent or unreadable |
| 288 |
files. Such files are quietly skipped. However, the return |
files. Such files are quietly skipped. However, the return |
| 289 |
code is still 2, even if matches were found in other files. |
code is still 2, even if matches were found in other files. |
| 290 |
|
|
| 291 |
-u, --utf-8 |
-u, --utf-8 |
| 292 |
Operate in UTF-8 mode. This option is available only if PCRE |
Operate in UTF-8 mode. This option is available only if PCRE |
| 293 |
has been compiled with UTF-8 support. Both patterns and sub- |
has been compiled with UTF-8 support. Both patterns and sub- |
| 294 |
ject lines must be valid strings of UTF-8 characters. |
ject lines must be valid strings of UTF-8 characters. |
| 295 |
|
|
| 296 |
-V, --version |
-V, --version |
| 297 |
Write the version numbers of pcregrep and the PCRE library |
Write the version numbers of pcregrep and the PCRE library |
| 298 |
that is being used to the standard error stream. |
that is being used to the standard error stream. |
| 299 |
|
|
| 300 |
-v, --invert-match |
-v, --invert-match |
| 301 |
Invert the sense of the match, so that lines which do not |
Invert the sense of the match, so that lines which do not |
| 302 |
match any of the patterns are the ones that are found. |
match any of the patterns are the ones that are found. |
| 303 |
|
|
| 304 |
-w, --word-regex, --word-regexp |
-w, --word-regex, --word-regexp |
| 306 |
lent to having \b at the start and end of the pattern. |
lent to having \b at the start and end of the pattern. |
| 307 |
|
|
| 308 |
-x, --line-regex, --line-regexp |
-x, --line-regex, --line-regexp |
| 309 |
Force the patterns to be anchored (each must start matching |
Force the patterns to be anchored (each must start matching |
| 310 |
at the beginning of a line) and in addition, require them to |
at the beginning of a line) and in addition, require them to |
| 311 |
match entire lines. This is equivalent to having ^ and $ |
match entire lines. This is equivalent to having ^ and $ |
| 312 |
characters at the start and end of each alternative branch in |
characters at the start and end of each alternative branch in |
| 313 |
every pattern. |
every pattern. |
| 314 |
|
|
| 315 |
|
|
| 316 |
ENVIRONMENT VARIABLES |
ENVIRONMENT VARIABLES |
| 317 |
|
|
| 318 |
The environment variables LC_ALL and LC_CTYPE are examined, in that |
The environment variables LC_ALL and LC_CTYPE are examined, in that |
| 319 |
order, for a locale. The first one that is set is used. This can be |
order, for a locale. The first one that is set is used. This can be |
| 320 |
overridden by the --locale option. If no locale is set, the PCRE |
overridden by the --locale option. If no locale is set, the PCRE |
| 321 |
library's default (usually the "C" locale) is used. |
library's default (usually the "C" locale) is used. |
| 322 |
|
|
| 323 |
|
|
| 324 |
|
NEWLINES |
| 325 |
|
|
| 326 |
|
The -N (--newline) option allows pcregrep to scan files with different |
| 327 |
|
newline conventions from the default. However, the setting of this |
| 328 |
|
option does not affect the way in which pcregrep writes information to |
| 329 |
|
the standard error and output streams. It uses the string "\n" in C |
| 330 |
|
printf() calls to indicate newlines, relying on the C I/O library to |
| 331 |
|
convert this to an appropriate sequence if the output is sent to a |
| 332 |
|
file. |
| 333 |
|
|
| 334 |
|
|
| 335 |
OPTIONS COMPATIBILITY |
OPTIONS COMPATIBILITY |
| 336 |
|
|
| 337 |
The majority of short and long forms of pcregrep's options are the same |
The majority of short and long forms of pcregrep's options are the same |
| 338 |
as in the GNU grep program. Any long option of the form --xxx-regexp |
as in the GNU grep program. Any long option of the form --xxx-regexp |
| 339 |
(GNU terminology) is also available as --xxx-regex (PCRE terminology). |
(GNU terminology) is also available as --xxx-regex (PCRE terminology). |
| 340 |
However, the --locale, -M, --multiline, -u, and --utf-8 options are |
However, the --locale, -M, --multiline, -u, and --utf-8 options are |
| 341 |
specific to pcregrep. |
specific to pcregrep. |
| 342 |
|
|
| 343 |
|
|
| 344 |
OPTIONS WITH DATA |
OPTIONS WITH DATA |
| 345 |
|
|
| 346 |
There are four different ways in which an option with data can be spec- |
There are four different ways in which an option with data can be spec- |
| 347 |
ified. If a short form option is used, the data may follow immedi- |
ified. If a short form option is used, the data may follow immedi- |
| 348 |
ately, or in the next command line item. For example: |
ately, or in the next command line item. For example: |
| 349 |
|
|
| 350 |
-f/some/file |
-f/some/file |
| 351 |
-f /some/file |
-f /some/file |
| 352 |
|
|
| 353 |
If a long form option is used, the data may appear in the same command |
If a long form option is used, the data may appear in the same command |
| 354 |
line item, separated by an equals character, or (with one exception) it |
line item, separated by an equals character, or (with one exception) it |
| 355 |
may appear in the next command line item. For example: |
may appear in the next command line item. For example: |
| 356 |
|
|
| 357 |
--file=/some/file |
--file=/some/file |
| 358 |
--file /some/file |
--file /some/file |
| 359 |
|
|
| 360 |
Note, however, that if you want to supply a file name beginning with ~ |
Note, however, that if you want to supply a file name beginning with ~ |
| 361 |
as data in a shell command, and have the shell expand ~ to a home |
as data in a shell command, and have the shell expand ~ to a home |
| 362 |
directory, you must separate the file name from the option, because the |
directory, you must separate the file name from the option, because the |
| 363 |
shell does not treat ~ specially unless it is at the start of an item. |
shell does not treat ~ specially unless it is at the start of an item. |
| 364 |
|
|
| 365 |
The exception to the above is the --colour (or --color) option, for |
The exception to the above is the --colour (or --color) option, for |
| 366 |
which the data is optional. If this option does have data, it must be |
which the data is optional. If this option does have data, it must be |
| 367 |
given in the first form, using an equals character. Otherwise it will |
given in the first form, using an equals character. Otherwise it will |
| 368 |
be assumed that it has no data. |
be assumed that it has no data. |
| 369 |
|
|
| 370 |
|
|
| 371 |
MATCHING ERRORS |
MATCHING ERRORS |
| 372 |
|
|
| 373 |
It is possible to supply a regular expression that takes a very long |
It is possible to supply a regular expression that takes a very long |
| 374 |
time to fail to match certain lines. Such patterns normally involve |
time to fail to match certain lines. Such patterns normally involve |
| 375 |
nested indefinite repeats, for example: (a+)*\d when matched against a |
nested indefinite repeats, for example: (a+)*\d when matched against a |
| 376 |
line of a's with no final digit. The PCRE matching function has a |
line of a's with no final digit. The PCRE matching function has a |
| 377 |
resource limit that causes it to abort in these circumstances. If this |
resource limit that causes it to abort in these circumstances. If this |
| 378 |
happens, pcregrep outputs an error message and the line that caused the |
happens, pcregrep outputs an error message and the line that caused the |
| 379 |
problem to the standard error stream. If there are more than 20 such |
problem to the standard error stream. If there are more than 20 such |
| 380 |
errors, pcregrep gives up. |
errors, pcregrep gives up. |
| 381 |
|
|
| 382 |
|
|
| 383 |
DIAGNOSTICS |
DIAGNOSTICS |
| 384 |
|
|
| 385 |
Exit status is 0 if any matches were found, 1 if no matches were found, |
Exit status is 0 if any matches were found, 1 if no matches were found, |
| 386 |
and 2 for syntax errors and non-existent or inacessible files (even if |
and 2 for syntax errors and non-existent or inacessible files (even if |
| 387 |
matches were found in other files) or too many matching errors. Using |
matches were found in other files) or too many matching errors. Using |
| 388 |
the -s option to suppress error messages about inaccessble files does |
the -s option to suppress error messages about inaccessble files does |
| 389 |
not affect the return code. |
not affect the return code. |
| 390 |
|
|
| 391 |
|
|
| 395 |
University Computing Service |
University Computing Service |
| 396 |
Cambridge CB2 3QG, England. |
Cambridge CB2 3QG, England. |
| 397 |
|
|
| 398 |
Last updated: 23 January 2006 |
Last updated: 06 June 2006 |
| 399 |
Copyright (c) 1997-2006 University of Cambridge. |
Copyright (c) 1997-2006 University of Cambridge. |