| 2 |
.SH NAME |
.SH NAME |
| 3 |
pcregrep - a grep with Perl-compatible regular expressions. |
pcregrep - a grep with Perl-compatible regular expressions. |
| 4 |
.SH SYNOPSIS |
.SH SYNOPSIS |
| 5 |
.B pcregrep [options] [long options] [pattern] [file1 file2 ...] |
.B pcregrep [options] [long options] [pattern] [path1 path2 ...] |
| 6 |
. |
. |
| 7 |
.SH DESCRIPTION |
.SH DESCRIPTION |
| 8 |
.rs |
.rs |
| 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 |
A pattern must be specified on the command line unless the \fB-f\fP option is |
Patterns, whether supplied on the command line or in a separate file, are given |
| 20 |
used (see below). |
without delimiters. For example: |
| 21 |
|
.sp |
| 22 |
|
pcregrep Thursday /etc/motd |
| 23 |
|
.sp |
| 24 |
|
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 |
| 26 |
|
pattern. Quotes can of course be used on the command line because they are |
| 27 |
|
interpreted by the shell, and indeed they are required if a pattern contains |
| 28 |
|
white space or shell metacharacters. |
| 29 |
|
.P |
| 30 |
|
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. |
| 32 |
|
Conversely, when one or both of these options are used to specify patterns, all |
| 33 |
|
arguments are treated as path names. At least one of \fB-e\fP, \fB-f\fP, or an |
| 34 |
|
argument pattern must be provided. |
| 35 |
.P |
.P |
| 36 |
If no files are specified, \fBpcregrep\fP reads the standard input. The |
If no files are specified, \fBpcregrep\fP reads the standard input. The |
| 37 |
standard input can also be referenced by a name consisting of a single hyphen. |
standard input can also be referenced by a name consisting of a single hyphen. |
| 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 the pattern is copied to the standard |
| 43 |
output, and if there is more than one file, the file name is printed before |
output, and if there is more than one file, the file name is output at the |
| 44 |
each line of output. However, there are options that can change how |
start of each line. However, there are options that can change how |
| 45 |
\fBpcregrep\fP behaves. In particular, the \fB-M\fP option makes it possible to |
\fBpcregrep\fP behaves. In particular, the \fB-M\fP option makes it possible to |
| 46 |
search for patterns that span line boundaries. |
search for patterns that span line boundaries. What defines a line boundary is |
| 47 |
|
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. |
| 51 |
|
.P |
| 52 |
|
If the \fBLC_ALL\fP or \fBLC_CTYPE\fP environment variable is set, |
| 53 |
|
\fBpcregrep\fP uses the value to set a locale when calling the PCRE library. |
| 54 |
|
The \fB--locale\fP option can be used to override this. |
| 55 |
. |
. |
| 56 |
.SH OPTIONS |
.SH OPTIONS |
| 57 |
.rs |
.rs |
| 58 |
.TP 10 |
.TP 10 |
| 59 |
\fB--\fP |
\fB--\fP |
| 60 |
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 |
| 61 |
command line starts with a hyphen, but is not an option. |
command line starts with a hyphen but is not an option. This allows for the |
| 62 |
|
processing of patterns and filenames that start with hyphens. |
| 63 |
.TP |
.TP |
| 64 |
\fB-A\fP \fInumber\fP |
\fB-A\fP \fInumber\fP, \fB--after-context=\fP\fInumber\fP |
| 65 |
Print \fInumber\fP lines of context after each matching line. If file names |
Output \fInumber\fP lines of context after each matching line. If filenames |
| 66 |
and/or line numbers are being printed, a hyphen separator is used instead of a |
and/or line numbers are being output, a hyphen separator is used instead of a |
| 67 |
colon for the context lines. A line containing "--" is printed between each |
colon for the context lines. A line containing "--" is output between each |
| 68 |
group of lines, unless they are in fact contiguous in the input file. The value |
group of lines, unless they are in fact contiguous in the input file. The value |
| 69 |
of \fInumber\fP is expected to be relatively small. However, \fBpcregrep\fP |
of \fInumber\fP is expected to be relatively small. However, \fBpcregrep\fP |
| 70 |
guarantees to have up to 8K of following text available for context printing. |
guarantees to have up to 8K of following text available for context output. |
| 71 |
.TP |
.TP |
| 72 |
\fB-B\fP \fInumber\fP |
\fB-B\fP \fInumber\fP, \fB--before-context=\fP\fInumber\fP |
| 73 |
Print \fInumber\fP lines of context before each matching line. If file names |
Output \fInumber\fP lines of context before each matching line. If filenames |
| 74 |
and/or line numbers are being printed, a hyphen separator is used instead of a |
and/or line numbers are being output, a hyphen separator is used instead of a |
| 75 |
colon for the context lines. A line containing "--" is printed between each |
colon for the context lines. A line containing "--" is output between each |
| 76 |
group of lines, unless they are in fact contiguous in the input file. The value |
group of lines, unless they are in fact contiguous in the input file. The value |
| 77 |
of \fInumber\fP is expected to be relatively small. However, \fBpcregrep\fP |
of \fInumber\fP is expected to be relatively small. However, \fBpcregrep\fP |
| 78 |
guarantees to have up to 8K of preceding text available for context printing. |
guarantees to have up to 8K of preceding text available for context output. |
| 79 |
.TP |
.TP |
| 80 |
\fB-C\fP \fInumber\fP |
\fB-C\fP \fInumber\fP, \fB--context=\fP\fInumber\fP |
| 81 |
Print \fInumber\fP lines of context both before and after each matching line. |
Output \fInumber\fP lines of context both before and after each matching line. |
| 82 |
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. |
| 83 |
.TP |
.TP |
| 84 |
\fB-c\fP |
\fB-c\fP, \fB--count\fP |
| 85 |
Do not print individual lines; instead just print a count of the number of |
Do not output individual lines; instead just output a count of the number of |
| 86 |
lines that would otherwise have been printed. If several files are given, a |
lines that would otherwise have been output. If several files are given, a |
| 87 |
count is printed for each of them. |
count is output for each of them. In this mode, the \fB-A\fP, \fB-B\fP, and |
| 88 |
|
\fB-C\fP options are ignored. |
| 89 |
|
.TP |
| 90 |
|
\fB--colour\fP, \fB--color\fP |
| 91 |
|
If this option is given without any data, it is equivalent to "--colour=auto". |
| 92 |
|
If data is required, it must be given in the same shell item, separated by an |
| 93 |
|
equals sign. |
| 94 |
|
.TP |
| 95 |
|
\fB--colour=\fP\fIvalue\fP, \fB--color=\fP\fIvalue\fP |
| 96 |
|
This option specifies under what circumstances the part of a line that matched |
| 97 |
|
a pattern should be coloured in the output. The value may be "never" (the |
| 98 |
|
default), "always", or "auto". In the latter case, colouring happens only if |
| 99 |
|
the standard output is connected to a terminal. The colour can be specified by |
| 100 |
|
setting the environment variable PCREGREP_COLOUR or PCREGREP_COLOR. The value |
| 101 |
|
of this variable should be a string of two numbers, separated by a semicolon. |
| 102 |
|
They are copied directly into the control string for setting colour on a |
| 103 |
|
terminal, so it is your responsibility to ensure that they make sense. If |
| 104 |
|
neither of the environment variables is set, the default is "1;31", which gives |
| 105 |
|
red. |
| 106 |
|
.TP |
| 107 |
|
\fB-D\fP \fIaction\fP, \fB--devices=\fP\fIaction\fP |
| 108 |
|
If an input path is not a regular file or a directory, "action" specifies how |
| 109 |
|
it is to be processed. Valid values are "read" (the default) or "skip" |
| 110 |
|
(silently skip the path). |
| 111 |
|
.TP |
| 112 |
|
\fB-d\fP \fIaction\fP, \fB--directories=\fP\fIaction\fP |
| 113 |
|
If an input path is a directory, "action" specifies how it is to be processed. |
| 114 |
|
Valid values are "read" (the default), "recurse" (equivalent to the \fB-r\fP |
| 115 |
|
option), or "skip" (silently skip the path). In the default case, directories |
| 116 |
|
are read as if they were ordinary files. In some operating systems the effect |
| 117 |
|
of reading a directory like this is an immediate end-of-file. |
| 118 |
|
.TP |
| 119 |
|
\fB-e\fP \fIpattern\fP, \fB--regex=\fP\fIpattern\fP, |
| 120 |
|
\fB--regexp=\fP\fIpattern\fP Specify a pattern to be matched. This option can |
| 121 |
|
be used multiple times in order to specify several patterns. It can also be |
| 122 |
|
used as a way of specifying a single pattern that starts with a hyphen. When |
| 123 |
|
\fB-e\fP is used, no argument pattern is taken from the command line; all |
| 124 |
|
arguments are treated as file names. There is an overall maximum of 100 |
| 125 |
|
patterns. They are applied to each line in the order in which they are defined |
| 126 |
|
until one matches (or fails to match if \fB-v\fP is used). If \fB-f\fP is used |
| 127 |
|
with \fB-e\fP, the command line patterns are matched first, followed by the |
| 128 |
|
patterns from the file, independent of the order in which these options are |
| 129 |
|
specified. Note that multiple use of \fB-e\fP is not the same as a single |
| 130 |
|
pattern with alternatives. For example, X|Y finds the first character in a line |
| 131 |
|
that is X or Y, whereas if the two patterns are given separately, |
| 132 |
|
\fBpcregrep\fP finds X if it is present, even if it follows Y in the line. It |
| 133 |
|
finds Y only if there is no X in the line. This really matters only if you are |
| 134 |
|
using \fB-o\fP to show the portion of the line that matched. |
| 135 |
.TP |
.TP |
| 136 |
\fB--exclude\fP=\fIpattern\fP |
\fB--exclude\fP=\fIpattern\fP |
| 137 |
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 |
| 140 |
both \fB--include\fP and \fB--exclude\fP, it is excluded. There is no short |
both \fB--include\fP and \fB--exclude\fP, it is excluded. There is no short |
| 141 |
form for this option. |
form for this option. |
| 142 |
.TP |
.TP |
| 143 |
\fB-f\fP\fIfilename\fP |
\fB-F\fP, \fB--fixed-strings\fP |
| 144 |
Read a number of patterns from the file, one per line, and match all of them |
Interpret each pattern as a list of fixed strings, separated by newlines, |
| 145 |
against each line of input. A line is output if any of the patterns match it. |
instead of as a regular expression. The \fB-w\fP (match as a word) and \fB-x\fP |
| 146 |
When \fB-f\fP is used, no pattern is taken from the command line; all arguments |
(match whole line) options can be used with \fB-F\fP. They apply to each of the |
| 147 |
are treated as file names. There is a maximum of 100 patterns. Trailing white |
fixed strings. A line is selected if any of the fixed strings are found in it |
| 148 |
space is removed, and blank lines are ignored. An empty file contains no |
(subject to \fB-w\fP or \fB-x\fP, if present). |
| 149 |
patterns and therefore matches nothing. |
.TP |
| 150 |
|
\fB-f\fP \fIfilename\fP, \fB--file=\fP\fIfilename\fP |
| 151 |
|
Read a number of patterns from the file, one per line, and match them against |
| 152 |
|
each line of input. A data line is output if any of the patterns match it. The |
| 153 |
|
filename can be given as "-" to refer to the standard input. When \fB-f\fP is |
| 154 |
|
used, patterns specified on the command line using \fB-e\fP may also be |
| 155 |
|
present; they are tested before the file's patterns. However, no other pattern |
| 156 |
|
is taken from the command line; all arguments are treated as file names. There |
| 157 |
|
is an overall maximum of 100 patterns. Trailing white space is removed from |
| 158 |
|
each line, and blank lines are ignored. An empty file contains no patterns and |
| 159 |
|
therefore matches nothing. |
| 160 |
|
.TP |
| 161 |
|
\fB-H\fP, \fB--with-filename\fP |
| 162 |
|
Force the inclusion of the filename at the start of output lines when searching |
| 163 |
|
a single file. By default, the filename is not shown in this case. For matching |
| 164 |
|
lines, the filename is followed by a colon and a space; for context lines, a |
| 165 |
|
hyphen separator is used. If a line number is also being output, it follows the |
| 166 |
|
file name without a space. |
| 167 |
|
.TP |
| 168 |
|
\fB-h\fP, \fB--no-filename\fP |
| 169 |
|
Suppress the output filenames when searching multiple files. By default, |
| 170 |
|
filenames are shown when multiple files are searched. For matching lines, the |
| 171 |
|
filename is followed by a colon and a space; for context lines, a hyphen |
| 172 |
|
separator is used. If a line number is also being output, it follows the file |
| 173 |
|
name without a space. |
| 174 |
.TP |
.TP |
| 175 |
\fB-h\fP |
\fB--help\fP |
| 176 |
Suppress printing of filenames when searching multiple files. |
Output a brief help message and exit. |
| 177 |
.TP |
.TP |
| 178 |
\fB-i\fP |
\fB-i\fP, \fB--ignore-case\fP |
| 179 |
Ignore upper/lower case distinctions during comparisons. |
Ignore upper/lower case distinctions during comparisons. |
| 180 |
.TP |
.TP |
| 181 |
\fB--include\fP=\fIpattern\fP |
\fB--include\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, only files whose names match the |
the \fB-r\fP (recursive search) option, only those files whose names match the |
| 184 |
pattern are included. The pattern is a PCRE regular expression. If a file name |
pattern are included. The pattern is a PCRE regular expression. If a file name |
| 185 |
matches both \fB--include\fP and \fB--exclude\fP, it is excluded. There is no |
matches both \fB--include\fP and \fB--exclude\fP, it is excluded. There is no |
| 186 |
short form for this option. |
short form for this option. |
| 187 |
.TP |
.TP |
| 188 |
\fB-L\fP |
\fB-L\fP, \fB--files-without-match\fP |
| 189 |
Instead of printing lines from the files, just print the names of the files |
Instead of outputting lines from the files, just output the names of the files |
| 190 |
that do not contain any lines that would have been printed. Each file name is |
that do not contain any lines that would have been output. Each file name is |
| 191 |
printed once, on a separate line. |
output once, on a separate line. |
| 192 |
.TP |
.TP |
| 193 |
\fB-l\fP |
\fB-l\fP, \fB--files-with-matches\fP |
| 194 |
Instead of printing lines from the files, just print the names of the files |
Instead of outputting lines from the files, just output the names of the files |
| 195 |
containing lines that would have been printed. Each file name is printed |
containing lines that would have been output. Each file name is output |
| 196 |
once, on a separate line. |
once, on a separate line. Searching stops as soon as a matching line is found |
| 197 |
|
in a file. |
| 198 |
.TP |
.TP |
| 199 |
\fB--label\fP=\fIname\fP |
\fB--label\fP=\fIname\fP |
| 200 |
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 |
| 201 |
are being printed. If not supplied, "(standard input)" is used. There is no |
are being output. If not supplied, "(standard input)" is used. There is no |
| 202 |
short form for this option. |
short form for this option. |
| 203 |
.TP |
.TP |
| 204 |
\fB-M\fP |
\fB--locale\fP=\fIlocale-name\fP |
| 205 |
|
This option specifies a locale to be used for pattern matching. It overrides |
| 206 |
|
the value in the \fBLC_ALL\fP or \fBLC_CTYPE\fP environment variables. If no |
| 207 |
|
locale is specified, the PCRE library's default (usually the "C" locale) is |
| 208 |
|
used. There is no short form for this option. |
| 209 |
|
.TP |
| 210 |
|
\fB-M\fP, \fB--multiline\fP |
| 211 |
Allow patterns to match more than one line. When this option is given, patterns |
Allow patterns to match more than one line. When this option is given, patterns |
| 212 |
may usefully contain literal newline characters and internal occurrences of ^ |
may usefully contain literal newline characters and internal occurrences of ^ |
| 213 |
and $ characters. The output for any one match may consist of more than one |
and $ characters. The output for any one match may consist of more than one |
| 219 |
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) |
| 220 |
are guaranteed to be available for lookbehind assertions. |
are guaranteed to be available for lookbehind assertions. |
| 221 |
.TP |
.TP |
| 222 |
\fB-n\fP |
\fB-N\fP \fInewline-type\fP, \fB--newline=\fP\fInewline-type\fP |
| 223 |
Precede each line by its line number in the file. |
The PCRE library supports four different conventions for indicating |
| 224 |
.TP |
the ends of lines. They are the single-character sequences CR (carriage return) |
| 225 |
\fB-q\fP |
and LF (linefeed), the two-character sequence CRLF, and an "any" convention, in |
| 226 |
Work quietly, that is, display nothing except error messages. |
which any Unicode line ending sequence is assumed to end a line. The Unicode |
| 227 |
The exit status indicates whether or not any matches were found. |
sequences are the three just mentioned, plus VT (vertical tab, U+000B), FF |
| 228 |
|
(formfeed, U+000C), NEL (next line, U+0085), LS (line separator, U+2028), and |
| 229 |
|
PS (paragraph separator, U+0029). |
| 230 |
|
.sp |
| 231 |
|
When the PCRE library is built, a default line-ending sequence is specified. |
| 232 |
|
This is normally the standard sequence for the operating system. Unless |
| 233 |
|
otherwise specified by this option, \fBpcregrep\fP uses the library's default. |
| 234 |
|
The possible values for this option are CR, LF, CRLF, or ANY. This makes it |
| 235 |
|
possible to use \fBpcregrep\fP on files that have come from other environments |
| 236 |
|
without having to modify their line endings. If the data that is being scanned |
| 237 |
|
does not agree with the convention set by this option, \fBpcregrep\fP may |
| 238 |
|
behave in strange ways. |
| 239 |
|
.TP |
| 240 |
|
\fB-n\fP, \fB--line-number\fP |
| 241 |
|
Precede each output line by its line number in the file, followed by a colon |
| 242 |
|
and a space for matching lines or a hyphen and a space for context lines. If |
| 243 |
|
the filename is also being output, it precedes the line number. |
| 244 |
|
.TP |
| 245 |
|
\fB-o\fP, \fB--only-matching\fP |
| 246 |
|
Show only the part of the line that matched a pattern. In this mode, no |
| 247 |
|
context is shown. That is, the \fB-A\fP, \fB-B\fP, and \fB-C\fP options are |
| 248 |
|
ignored. |
| 249 |
|
.TP |
| 250 |
|
\fB-q\fP, \fB--quiet\fP |
| 251 |
|
Work quietly, that is, display nothing except error messages. The exit |
| 252 |
|
status indicates whether or not any matches were found. |
| 253 |
.TP |
.TP |
| 254 |
\fB-r\fP |
\fB-r\fP, \fB--recursive\fP |
| 255 |
If any given path is a directory, recursively scan the files it contains, |
If any given path is a directory, recursively scan the files it contains, |
| 256 |
taking note of any \fB--include\fP and \fB--exclude\fP settings. Without |
taking note of any \fB--include\fP and \fB--exclude\fP settings. By default, a |
| 257 |
\fB-r\fP a directory is scanned as a normal file. |
directory is read as a normal file; in some operating systems this gives an |
| 258 |
|
immediate end-of-file. This option is a shorthand for setting the \fB-d\fP |
| 259 |
|
option to "recurse". |
| 260 |
.TP |
.TP |
| 261 |
\fB-s\fP |
\fB-s\fP, \fB--no-messages\fP |
| 262 |
Suppress error messages about non-existent or unreadable files. Such files are |
Suppress error messages about non-existent or unreadable files. Such files are |
| 263 |
quietly skipped. However, the return code is still 2, even if matches were |
quietly skipped. However, the return code is still 2, even if matches were |
| 264 |
found in other files. |
found in other files. |
| 265 |
.TP |
.TP |
| 266 |
\fB-u\fP |
\fB-u\fP, \fB--utf-8\fP |
| 267 |
Operate in UTF-8 mode. This option is available only if PCRE has been compiled |
Operate in UTF-8 mode. This option is available only if PCRE has been compiled |
| 268 |
with UTF-8 support. Both the pattern and each subject line must be valid |
with UTF-8 support. Both patterns and subject lines must be valid strings of |
| 269 |
strings of UTF-8 characters. |
UTF-8 characters. |
| 270 |
.TP |
.TP |
| 271 |
\fB-V\fP |
\fB-V\fP, \fB--version\fP |
| 272 |
Write the version numbers of \fBpcregrep\fP and the PCRE library that is being |
Write the version numbers of \fBpcregrep\fP and the PCRE library that is being |
| 273 |
used to the standard error stream. |
used to the standard error stream. |
| 274 |
.TP |
.TP |
| 275 |
\fB-v\fP |
\fB-v\fP, \fB--invert-match\fP |
| 276 |
Invert the sense of the match, so that lines which do \fInot\fP match the |
Invert the sense of the match, so that lines which do \fInot\fP match any of |
| 277 |
pattern are the ones that are found. |
the patterns are the ones that are found. |
| 278 |
.TP |
.TP |
| 279 |
\fB-w\fP |
\fB-w\fP, \fB--word-regex\fP, \fB--word-regexp\fP |
| 280 |
Force the pattern 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 |
| 281 |
at the start and end of the pattern. |
at the start and end of the pattern. |
| 282 |
.TP |
.TP |
| 283 |
\fB-x\fP |
\fB-x\fP, \fB--line-regex\fP, \fP--line-regexp\fP |
| 284 |
Force the pattern to be anchored (it must start matching at the beginning of |
Force the patterns to be anchored (each must start matching at the beginning of |
| 285 |
the line) and in addition, require it to match the entire line. This is |
a line) and in addition, require them to match entire lines. This is |
| 286 |
equivalent to having ^ and $ characters at the start and end of each |
equivalent to having ^ and $ characters at the start and end of each |
| 287 |
alternative branch in the regular expression. |
alternative branch in every pattern. |
| 288 |
. |
. |
| 289 |
.SH "LONG OPTIONS" |
. |
| 290 |
|
.SH "ENVIRONMENT VARIABLES" |
| 291 |
.rs |
.rs |
| 292 |
.sp |
.sp |
| 293 |
Long forms of all the options are available, as in GNU grep. They are shown in |
The environment variables \fBLC_ALL\fP and \fBLC_CTYPE\fP are examined, in that |
| 294 |
the following table: |
order, for a locale. The first one that is set is used. This can be overridden |
| 295 |
|
by the \fB--locale\fP option. If no locale is set, the PCRE library's default |
| 296 |
|
(usually the "C" locale) is used. |
| 297 |
|
. |
| 298 |
|
. |
| 299 |
|
.SH "NEWLINES" |
| 300 |
|
.rs |
| 301 |
.sp |
.sp |
| 302 |
-A --after-context |
The \fB-N\fP (\fB--newline\fP) option allows \fBpcregrep\fP to scan files with |
| 303 |
-B --before-context |
different newline conventions from the default. However, the setting of this |
| 304 |
-C --context |
option does not affect the way in which \fBpcregrep\fP writes information to |
| 305 |
-c --count |
the standard error and output streams. It uses the string "\en" in C |
| 306 |
--exclude (no short form) |
\fBprintf()\fP calls to indicate newlines, relying on the C I/O library to |
| 307 |
-f --file |
convert this to an appropriate sequence if the output is sent to a file. |
| 308 |
-h --no-filename |
. |
| 309 |
--help (no short form) |
. |
| 310 |
-i --ignore-case |
.SH "OPTIONS COMPATIBILITY" |
| 311 |
--include (no short form) |
.rs |
| 312 |
-L --files-without-match |
.sp |
| 313 |
-l --files-with-matches |
The majority of short and long forms of \fBpcregrep\fP's options are the same |
| 314 |
--label (no short form) |
as in the GNU \fBgrep\fP program. Any long option of the form |
| 315 |
-n --line-number |
\fB--xxx-regexp\fP (GNU terminology) is also available as \fB--xxx-regex\fP |
| 316 |
-r --recursive |
(PCRE terminology). However, the \fB--locale\fP, \fB-M\fP, \fB--multiline\fP, |
| 317 |
-q --quiet |
\fB-u\fP, and \fB--utf-8\fP options are specific to \fBpcregrep\fP. |
| 318 |
-s --no-messages |
. |
|
-u --utf-8 |
|
|
-V --version |
|
|
-v --invert-match |
|
|
-x --line-regex |
|
|
-x --line-regexp |
|
| 319 |
. |
. |
| 320 |
.SH "OPTIONS WITH DATA" |
.SH "OPTIONS WITH DATA" |
| 321 |
.rs |
.rs |
| 328 |
-f /some/file |
-f /some/file |
| 329 |
.sp |
.sp |
| 330 |
If a long form option is used, the data may appear in the same command line |
If a long form option is used, the data may appear in the same command line |
| 331 |
item, separated by an = character, or it may appear in the next command line |
item, separated by an equals character, or (with one exception) it may appear |
| 332 |
item. For example: |
in the next command line item. For example: |
| 333 |
.sp |
.sp |
| 334 |
--file=/some/file |
--file=/some/file |
| 335 |
--file /some/file |
--file /some/file |
| 336 |
.sp |
.sp |
| 337 |
|
Note, however, that if you want to supply a file name beginning with ~ as data |
| 338 |
|
in a shell command, and have the shell expand ~ to a home directory, you must |
| 339 |
|
separate the file name from the option, because the shell does not treat ~ |
| 340 |
|
specially unless it is at the start of an item. |
| 341 |
|
.P |
| 342 |
|
The exception to the above is the \fB--colour\fP (or \fB--color\fP) option, |
| 343 |
|
for which the data is optional. If this option does have data, it must be given |
| 344 |
|
in the first form, using an equals character. Otherwise it will be assumed that |
| 345 |
|
it has no data. |
| 346 |
|
. |
| 347 |
|
. |
| 348 |
|
.SH "MATCHING ERRORS" |
| 349 |
|
.rs |
| 350 |
|
.sp |
| 351 |
|
It is possible to supply a regular expression that takes a very long time to |
| 352 |
|
fail to match certain lines. Such patterns normally involve nested indefinite |
| 353 |
|
repeats, for example: (a+)*\ed when matched against a line of a's with no final |
| 354 |
|
digit. The PCRE matching function has a resource limit that causes it to abort |
| 355 |
|
in these circumstances. If this happens, \fBpcregrep\fP outputs an error |
| 356 |
|
message and the line that caused the problem to the standard error stream. If |
| 357 |
|
there are more than 20 such errors, \fBpcregrep\fP gives up. |
| 358 |
|
. |
| 359 |
. |
. |
| 360 |
.SH DIAGNOSTICS |
.SH DIAGNOSTICS |
| 361 |
.rs |
.rs |
| 362 |
.sp |
.sp |
| 363 |
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 |
| 364 |
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 |
| 365 |
found in other files). Using the \fB-s\fP option to suppress error messages |
found in other files) or too many matching errors. Using the \fB-s\fP option to |
| 366 |
about inaccessble files does not affect the return code. |
suppress error messages about inaccessble files does not affect the return |
| 367 |
|
code. |
| 368 |
|
. |
| 369 |
|
. |
| 370 |
|
.SH "SEE ALSO" |
| 371 |
|
.rs |
| 372 |
|
.sp |
| 373 |
|
\fBpcrepattern\fP(3), \fBpcretest\fP(1). |
| 374 |
. |
. |
| 375 |
. |
. |
| 376 |
.SH AUTHOR |
.SH AUTHOR |
| 377 |
.rs |
.rs |
| 378 |
.sp |
.sp |
| 379 |
|
.nf |
| 380 |
Philip Hazel |
Philip Hazel |
|
.br |
|
| 381 |
University Computing Service |
University Computing Service |
| 382 |
.br |
Cambridge CB2 3QH, England. |
| 383 |
Cambridge CB2 3QG, England. |
.fi |
| 384 |
.P |
. |
| 385 |
.in 0 |
. |
| 386 |
Last updated: 16 May 2005 |
.SH REVISION |
| 387 |
.br |
.rs |
| 388 |
Copyright (c) 1997-2005 University of Cambridge. |
.sp |
| 389 |
|
.nf |
| 390 |
|
Last updated: 06 March 2007 |
| 391 |
|
Copyright (c) 1997-2007 University of Cambridge. |
| 392 |
|
.fi |