~ubuntu-branches/ubuntu/trusty/pcre3/trusty

« back to all changes in this revision

Viewing changes to doc/pcregrep.txt

  • Committer: Package Import Robot
  • Author(s): Mark Baker
  • Date: 2012-03-23 22:34:54 UTC
  • mfrom: (23.1.9 sid)
  • Revision ID: package-import@ubuntu.com-20120323223454-grhqqolk8a7x1h24
Tags: 1:8.30-4
* Reluctantly using an epoch, as it seems the funny version number with
  extra dots causes problems
* Bumped standard version to 3.9.3. No changes needed
* Converted to use new source format / quilt
* Put back obsolete pcre_info() API that upstream have dropped (Closes:
  #665300, #665356)
* Don't include pcregrep binary in debug package

Thanks to Elimar Riesebieter for the conversion to the new source format.

Show diffs side-by-side

added added

removed removed

Lines of Context:
49
49
       What defines a line  boundary  is  controlled  by  the  -N  (--newline)
50
50
       option.
51
51
 
52
 
       Patterns  are  limited  to  8K  or  BUFSIZ characters, whichever is the
53
 
       greater.  BUFSIZ is defined in <stdio.h>. When there is more  than  one
54
 
       pattern (specified by the use of -e and/or -f), each pattern is applied
55
 
       to each line in the order in which they are defined,  except  that  all
56
 
       the -e patterns are tried before the -f patterns.
57
 
 
58
 
       By  default,  as soon as one pattern matches (or fails to match when -v
59
 
       is used), no further patterns are considered. However, if --colour  (or
 
52
       The amount of memory used for buffering files that are being scanned is
 
53
       controlled by a parameter that can be set by the --buffer-size  option.
 
54
       The  default  value  for  this  parameter is specified when pcregrep is
 
55
       built, with the default default being 20K.  A  block  of  memory  three
 
56
       times  this  size  is used (to allow for buffering "before" and "after"
 
57
       lines). An error occurs if a line overflows the buffer.
 
58
 
 
59
       Patterns are limited to 8K or BUFSIZ bytes, whichever is  the  greater.
 
60
       BUFSIZ  is  defined  in  <stdio.h>. When there is more than one pattern
 
61
       (specified by the use of -e and/or -f), each pattern is applied to each
 
62
       line  in  the  order  in which they are defined, except that all the -e
 
63
       patterns are tried before the -f patterns.
 
64
 
 
65
       By default, as soon as one pattern matches (or fails to match  when  -v
 
66
       is  used), no further patterns are considered. However, if --colour (or
60
67
       --color) is used to colour the matching substrings, or if --only-match-
61
 
       ing, --file-offsets, or --line-offsets is used to output only the  part
62
 
       of  the  line  that  matched (either shown literally, or as an offset),
63
 
       scanning resumes immediately  following  the  match,  so  that  further
64
 
       matches  on the same line can be found. If there are multiple patterns,
 
68
       ing,  --file-offsets, or --line-offsets is used to output only the part
 
69
       of the line that matched (either shown literally,  or  as  an  offset),
 
70
       scanning  resumes  immediately  following  the  match,  so that further
 
71
       matches on the same line can be found. If there are multiple  patterns,
65
72
       they are all tried on the remainder of the line, but patterns that fol-
66
73
       low the one that matched are not tried on the earlier part of the line.
67
74
 
69
76
       in which multiple patterns are specified can affect the output when one
70
77
       of the above options is used.
71
78
 
72
 
       Patterns  that can match an empty string are accepted, but empty string
 
79
       Patterns that can match an empty string are accepted, but empty  string
73
80
       matches   are   never   recognized.   An   example   is   the   pattern
74
 
       "(super)?(man)?",  in  which  all components are optional. This pattern
75
 
       finds all occurrences of both "super" and  "man";  the  output  differs
76
 
       from  matching  with  "super|man" when only the matching substrings are
 
81
       "(super)?(man)?", in which all components are  optional.  This  pattern
 
82
       finds  all  occurrences  of  both "super" and "man"; the output differs
 
83
       from matching with "super|man" when only the  matching  substrings  are
77
84
       being shown.
78
85
 
79
 
       If the LC_ALL or LC_CTYPE environment variable is  set,  pcregrep  uses
80
 
       the  value to set a locale when calling the PCRE library.  The --locale
 
86
       If  the  LC_ALL  or LC_CTYPE environment variable is set, pcregrep uses
 
87
       the value to set a locale when calling the PCRE library.  The  --locale
81
88
       option can be used to override this.
82
89
 
83
90
 
84
91
SUPPORT FOR COMPRESSED FILES
85
92
 
86
 
       It is possible to compile pcregrep so that it uses libz  or  libbz2  to
87
 
       read  files  whose names end in .gz or .bz2, respectively. You can find
 
93
       It  is  possible  to compile pcregrep so that it uses libz or libbz2 to
 
94
       read files whose names end in .gz or .bz2, respectively. You  can  find
88
95
       out whether your binary has support for one or both of these file types
89
96
       by running it with the --help option. If the appropriate support is not
90
 
       present, files are treated as plain text. The standard input is  always
 
97
       present,  files are treated as plain text. The standard input is always
91
98
       so treated.
92
99
 
93
100
 
94
101
OPTIONS
95
102
 
96
 
       The  order  in  which some of the options appear can affect the output.
97
 
       For example, both the -h and -l options affect  the  printing  of  file
98
 
       names.  Whichever  comes later in the command line will be the one that
99
 
       takes effect.
 
103
       The order in which some of the options appear can  affect  the  output.
 
104
       For  example,  both  the  -h and -l options affect the printing of file
 
105
       names. Whichever comes later in the command line will be the  one  that
 
106
       takes  effect.  Numerical values for options may be followed by K or M,
 
107
       to signify multiplication by 1024 or 1024*1024 respectively.
100
108
 
101
 
       --        This terminate the list of options. It is useful if the  next
 
109
       --        This terminates the list of options. It is useful if the next
102
110
                 item  on  the command line starts with a hyphen but is not an
103
111
                 option. This allows for the processing of patterns and  file-
104
112
                 names that start with hyphens.
123
131
                 pcregrep guarantees to have up to 8K of preceding text avail-
124
132
                 able for context output.
125
133
 
 
134
       --buffer-size=number
 
135
                 Set  the  parameter that controls how much memory is used for
 
136
                 buffering files that are being scanned.
 
137
 
126
138
       -C number, --context=number
127
 
                 Output  number  lines  of  context both before and after each
128
 
                 matching line.  This is equivalent to setting both -A and  -B
 
139
                 Output number lines of context both  before  and  after  each
 
140
                 matching  line.  This is equivalent to setting both -A and -B
129
141
                 to the same value.
130
142
 
131
143
       -c, --count
132
 
                 Do  not output individual lines from the files that are being
 
144
                 Do not output individual lines from the files that are  being
133
145
                 scanned; instead output the number of lines that would other-
134
 
                 wise  have  been  shown. If no lines are selected, the number
135
 
                 zero is output. If several files are  are  being  scanned,  a
136
 
                 count  is  output  for each of them. However, if the --files-
137
 
                 with-matches option is also  used,  only  those  files  whose
 
146
                 wise have been shown. If no lines are  selected,  the  number
 
147
                 zero  is  output.  If  several files are are being scanned, a
 
148
                 count is output for each of them. However,  if  the  --files-
 
149
                 with-matches  option  is  also  used,  only those files whose
138
150
                 counts are greater than zero are listed. When -c is used, the
139
151
                 -A, -B, and -C options are ignored.
140
152
 
141
153
       --colour, --color
142
154
                 If this option is given without any data, it is equivalent to
143
 
                 "--colour=auto".   If  data  is required, it must be given in
 
155
                 "--colour=auto".  If data is required, it must  be  given  in
144
156
                 the same shell item, separated by an equals sign.
145
157
 
146
158
       --colour=value, --color=value
147
159
                 This option specifies under what circumstances the parts of a
148
160
                 line that matched a pattern should be coloured in the output.
149
 
                 By default, the output is not coloured. The value  (which  is
150
 
                 optional,  see above) may be "never", "always", or "auto". In
151
 
                 the latter case, colouring happens only if the standard  out-
152
 
                 put  is connected to a terminal. More resources are used when
153
 
                 colouring is enabled, because pcregrep has to search for  all
154
 
                 possible  matches in a line, not just one, in order to colour
 
161
                 By  default,  the output is not coloured. The value (which is
 
162
                 optional, see above) may be "never", "always", or "auto".  In
 
163
                 the  latter case, colouring happens only if the standard out-
 
164
                 put is connected to a terminal. More resources are used  when
 
165
                 colouring  is enabled, because pcregrep has to search for all
 
166
                 possible matches in a line, not just one, in order to  colour
155
167
                 them all.
156
168
 
157
169
                 The colour that is used can be specified by setting the envi-
158
170
                 ronment variable PCREGREP_COLOUR or PCREGREP_COLOR. The value
159
171
                 of this variable should be a string of two numbers, separated
160
 
                 by  a  semicolon.  They  are copied directly into the control
161
 
                 string for setting colour  on  a  terminal,  so  it  is  your
162
 
                 responsibility  to ensure that they make sense. If neither of
163
 
                 the environment variables is  set,  the  default  is  "1;31",
 
172
                 by a semicolon. They are copied  directly  into  the  control
 
173
                 string  for  setting  colour  on  a  terminal,  so it is your
 
174
                 responsibility to ensure that they make sense. If neither  of
 
175
                 the  environment  variables  is  set,  the default is "1;31",
164
176
                 which gives red.
165
177
 
166
178
       -D action, --devices=action
167
 
                 If  an  input  path  is  not  a  regular file or a directory,
168
 
                 "action" specifies how it is to be  processed.  Valid  values
 
179
                 If an input path is  not  a  regular  file  or  a  directory,
 
180
                 "action"  specifies  how  it is to be processed. Valid values
169
181
                 are "read" (the default) or "skip" (silently skip the path).
170
182
 
171
183
       -d action, --directories=action
172
184
                 If an input path is a directory, "action" specifies how it is
173
 
                 to be processed.  Valid  values  are  "read"  (the  default),
174
 
                 "recurse"  (equivalent to the -r option), or "skip" (silently
175
 
                 skip the path). In the default case, directories are read  as
176
 
                 if  they  were  ordinary files. In some operating systems the
177
 
                 effect of reading a directory like this is an immediate  end-
 
185
                 to  be  processed.   Valid  values  are "read" (the default),
 
186
                 "recurse" (equivalent to the -r option), or "skip"  (silently
 
187
                 skip  the path). In the default case, directories are read as
 
188
                 if they were ordinary files. In some  operating  systems  the
 
189
                 effect  of reading a directory like this is an immediate end-
178
190
                 of-file.
179
191
 
180
192
       -e pattern, --regex=pattern, --regexp=pattern
181
193
                 Specify a pattern to be matched. This option can be used mul-
182
194
                 tiple times in order to specify several patterns. It can also
183
 
                 be  used  as a way of specifying a single pattern that starts
184
 
                 with a hyphen. When -e is used, no argument pattern is  taken
185
 
                 from  the  command  line;  all  arguments are treated as file
186
 
                 names. There is an overall maximum of 100 patterns. They  are
187
 
                 applied  to  each line in the order in which they are defined
 
195
                 be used as a way of specifying a single pattern  that  starts
 
196
                 with  a hyphen. When -e is used, no argument pattern is taken
 
197
                 from the command line; all  arguments  are  treated  as  file
 
198
                 names.  There is an overall maximum of 100 patterns. They are
 
199
                 applied to each line in the order in which they  are  defined
188
200
                 until one matches (or fails to match if -v is used). If -f is
189
 
                 used  with  -e,  the command line patterns are matched first,
190
 
                 followed by the patterns from the file,  independent  of  the
191
 
                 order  in which these options are specified. Note that multi-
 
201
                 used with -e, the command line patterns  are  matched  first,
 
202
                 followed  by  the  patterns from the file, independent of the
 
203
                 order in which these options are specified. Note that  multi-
192
204
                 ple use of -e is not the same as a single pattern with alter-
193
205
                 natives. For example, X|Y finds the first character in a line
194
 
                 that is X or Y, whereas if the two patterns are  given  sepa-
 
206
                 that  is  X or Y, whereas if the two patterns are given sepa-
195
207
                 rately, pcregrep finds X if it is present, even if it follows
196
 
                 Y in the line. It finds Y only if there is no X in the  line.
197
 
                 This  really  matters  only  if  you are using -o to show the
 
208
                 Y  in the line. It finds Y only if there is no X in the line.
 
209
                 This really matters only if you are  using  -o  to  show  the
198
210
                 part(s) of the line that matched.
199
211
 
200
212
       --exclude=pattern
201
213
                 When pcregrep is searching the files in a directory as a con-
202
 
                 sequence  of  the  -r  (recursive search) option, any regular
 
214
                 sequence of the -r (recursive  search)  option,  any  regular
203
215
                 files whose names match the pattern are excluded. Subdirecto-
204
 
                 ries  are  not  excluded  by  this  option; they are searched
205
 
                 recursively, subject to the --exclude-dir  and  --include_dir
206
 
                 options.  The  pattern  is  a PCRE regular expression, and is
 
216
                 ries are not excluded  by  this  option;  they  are  searched
 
217
                 recursively,  subject  to the --exclude-dir and --include_dir
 
218
                 options. The pattern is a PCRE  regular  expression,  and  is
207
219
                 matched against the final component of the file name (not the
208
 
                 entire  path).  If  a  file  name  matches both --include and
209
 
                 --exclude, it is excluded.  There is no short form  for  this
 
220
                 entire path). If a  file  name  matches  both  --include  and
 
221
                 --exclude,  it  is excluded.  There is no short form for this
210
222
                 option.
211
223
 
212
224
       --exclude-dir=pattern
213
 
                 When  pcregrep  is searching the contents of a directory as a
214
 
                 consequence of the -r (recursive search) option,  any  subdi-
215
 
                 rectories  whose  names match the pattern are excluded. (Note
216
 
                 that the --exclude option does  not  affect  subdirectories.)
217
 
                 The  pattern  is  a  PCRE  regular expression, and is matched
218
 
                 against the final component  of  the  name  (not  the  entire
219
 
                 path).  If a subdirectory name matches both --include-dir and
220
 
                 --exclude-dir, it is excluded. There is  no  short  form  for
 
225
                 When pcregrep is searching the contents of a directory  as  a
 
226
                 consequence  of  the -r (recursive search) option, any subdi-
 
227
                 rectories whose names match the pattern are  excluded.  (Note
 
228
                 that  the  --exclude  option does not affect subdirectories.)
 
229
                 The pattern is a PCRE  regular  expression,  and  is  matched
 
230
                 against  the  final  component  of  the  name (not the entire
 
231
                 path). If a subdirectory name matches both --include-dir  and
 
232
                 --exclude-dir,  it  is  excluded.  There is no short form for
221
233
                 this option.
222
234
 
223
235
       -F, --fixed-strings
224
 
                 Interpret  each pattern as a list of fixed strings, separated
225
 
                 by newlines, instead of  as  a  regular  expression.  The  -w
226
 
                 (match  as  a  word) and -x (match whole line) options can be
 
236
                 Interpret each pattern as a list of fixed strings,  separated
 
237
                 by  newlines,  instead  of  as  a  regular expression. The -w
 
238
                 (match as a word) and -x (match whole line)  options  can  be
227
239
                 used with -F. They apply to each of the fixed strings. A line
228
240
                 is selected if any of the fixed strings are found in it (sub-
229
241
                 ject to -w or -x, if present).
230
242
 
231
243
       -f filename, --file=filename
232
 
                 Read a number of patterns from the file, one  per  line,  and
233
 
                 match  them against each line of input. A data line is output
 
244
                 Read  a  number  of patterns from the file, one per line, and
 
245
                 match them against each line of input. A data line is  output
234
246
                 if any of the patterns match it. The filename can be given as
235
247
                 "-" to refer to the standard input. When -f is used, patterns
236
 
                 specified on the command line using -e may also  be  present;
 
248
                 specified  on  the command line using -e may also be present;
237
249
                 they are tested before the file's patterns. However, no other
238
 
                 pattern is taken from the command  line;  all  arguments  are
239
 
                 treated  as  file  names.  There is an overall maximum of 100
 
250
                 pattern  is  taken  from  the command line; all arguments are
 
251
                 treated as file names. There is an  overall  maximum  of  100
240
252
                 patterns. Trailing white space is removed from each line, and
241
 
                 blank  lines  are ignored. An empty file contains no patterns
242
 
                 and therefore matches nothing. See also  the  comments  about
243
 
                 multiple  patterns  versus a single pattern with alternatives
 
253
                 blank lines are ignored. An empty file contains  no  patterns
 
254
                 and  therefore  matches  nothing. See also the comments about
 
255
                 multiple patterns versus a single pattern  with  alternatives
244
256
                 in the description of -e above.
245
257
 
246
258
       --file-offsets
247
 
                 Instead of showing lines or parts of lines that  match,  show
248
 
                 each  match  as  an  offset  from the start of the file and a
249
 
                 length, separated by a comma. In this  mode,  no  context  is
250
 
                 shown.  That  is,  the -A, -B, and -C options are ignored. If
 
259
                 Instead  of  showing lines or parts of lines that match, show
 
260
                 each match as an offset from the start  of  the  file  and  a
 
261
                 length,  separated  by  a  comma. In this mode, no context is
 
262
                 shown. That is, the -A, -B, and -C options  are  ignored.  If
251
263
                 there is more than one match in a line, each of them is shown
252
 
                 separately.  This  option  is mutually exclusive with --line-
 
264
                 separately. This option is mutually  exclusive  with  --line-
253
265
                 offsets and --only-matching.
254
266
 
255
267
       -H, --with-filename
256
 
                 Force the inclusion of the filename at the  start  of  output
257
 
                 lines  when searching a single file. By default, the filename
258
 
                 is not shown in this case. For matching lines,  the  filename
 
268
                 Force  the  inclusion  of the filename at the start of output
 
269
                 lines when searching a single file. By default, the  filename
 
270
                 is  not  shown in this case. For matching lines, the filename
259
271
                 is followed by a colon; for context lines, a hyphen separator
260
 
                 is used. If a line number is also being  output,  it  follows
 
272
                 is  used.  If  a line number is also being output, it follows
261
273
                 the file name.
262
274
 
263
275
       -h, --no-filename
264
 
                 Suppress  the output filenames when searching multiple files.
265
 
                 By default, filenames  are  shown  when  multiple  files  are
266
 
                 searched.  For  matching lines, the filename is followed by a
267
 
                 colon; for context lines, a hyphen separator is used.   If  a
 
276
                 Suppress the output filenames when searching multiple  files.
 
277
                 By  default,  filenames  are  shown  when  multiple files are
 
278
                 searched. For matching lines, the filename is followed  by  a
 
279
                 colon;  for  context lines, a hyphen separator is used.  If a
268
280
                 line number is also being output, it follows the file name.
269
281
 
270
 
       --help    Output  a  help  message, giving brief details of the command
 
282
       --help    Output a help message, giving brief details  of  the  command
271
283
                 options and file type support, and then exit.
272
284
 
273
285
       -i, --ignore-case
277
289
                 When pcregrep is searching the files in a directory as a con-
278
290
                 sequence of the -r (recursive search) option, only those reg-
279
291
                 ular files whose names match the pattern are included. Subdi-
280
 
                 rectories  are always included and searched recursively, sub-
 
292
                 rectories are always included and searched recursively,  sub-
281
293
                 ject to the --include-dir and --exclude-dir options. The pat-
282
294
                 tern is a PCRE regular expression, and is matched against the
283
 
                 final component of the file name (not the entire path). If  a
 
295
                 final  component of the file name (not the entire path). If a
284
296
                 file  name  matches  both  --include  and  --exclude,  it  is
285
297
                 excluded. There is no short form for this option.
286
298
 
287
299
       --include-dir=pattern
288
 
                 When pcregrep is searching the contents of a directory  as  a
289
 
                 consequence  of  the -r (recursive search) option, only those
290
 
                 subdirectories whose names match the  pattern  are  included.
291
 
                 (Note  that  the --include option does not affect subdirecto-
292
 
                 ries.) The pattern is  a  PCRE  regular  expression,  and  is
293
 
                 matched  against  the  final  component  of the name (not the
294
 
                 entire path). If a subdirectory name matches both  --include-
 
300
                 When  pcregrep  is searching the contents of a directory as a
 
301
                 consequence of the -r (recursive search) option,  only  those
 
302
                 subdirectories  whose  names  match the pattern are included.
 
303
                 (Note that the --include option does not  affect  subdirecto-
 
304
                 ries.)  The  pattern  is  a  PCRE  regular expression, and is
 
305
                 matched against the final component  of  the  name  (not  the
 
306
                 entire  path). If a subdirectory name matches both --include-
295
307
                 dir and --exclude-dir, it is excluded. There is no short form
296
308
                 for this option.
297
309
 
298
310
       -L, --files-without-match
299
 
                 Instead of outputting lines from the files, just  output  the
300
 
                 names  of  the files that do not contain any lines that would
301
 
                 have been output. Each file name is output once, on  a  sepa-
 
311
                 Instead  of  outputting lines from the files, just output the
 
312
                 names of the files that do not contain any lines  that  would
 
313
                 have  been  output. Each file name is output once, on a sepa-
302
314
                 rate line.
303
315
 
304
316
       -l, --files-with-matches
305
 
                 Instead  of  outputting lines from the files, just output the
 
317
                 Instead of outputting lines from the files, just  output  the
306
318
                 names of the files containing lines that would have been out-
307
 
                 put.  Each  file  name  is  output  once, on a separate line.
308
 
                 Searching normally stops as soon as a matching line is  found
309
 
                 in  a  file.  However, if the -c (count) option is also used,
310
 
                 matching continues in order to obtain the correct count,  and
311
 
                 those  files  that  have  at least one match are listed along
 
319
                 put. Each file name is  output  once,  on  a  separate  line.
 
320
                 Searching  normally stops as soon as a matching line is found
 
321
                 in a file. However, if the -c (count) option  is  also  used,
 
322
                 matching  continues in order to obtain the correct count, and
 
323
                 those files that have at least one  match  are  listed  along
312
324
                 with their counts. Using this option with -c is a way of sup-
313
325
                 pressing the listing of files with no matches.
314
326
 
318
330
                 input)" is used. There is no short form for this option.
319
331
 
320
332
       --line-buffered
321
 
                 When  this  option is given, input is read and processed line
322
 
                 by line, and the output  is  flushed  after  each  write.  By
323
 
                 default,  input  is read in large chunks, unless pcregrep can
324
 
                 determine that it is reading from a terminal (which  is  cur-
325
 
                 rently  possible only in Unix environments). Output to termi-
326
 
                 nal is normally automatically flushed by the  operating  sys-
327
 
                 tem.  This  option  can be useful when the input or output is
328
 
                 attached to a pipe and you do not want pcregrep to buffer  up
329
 
                 large  amounts  of data. However, its use will affect perfor-
 
333
                 When this option is given, input is read and  processed  line
 
334
                 by  line,  and  the  output  is  flushed after each write. By
 
335
                 default, input is read in large chunks, unless  pcregrep  can
 
336
                 determine  that  it is reading from a terminal (which is cur-
 
337
                 rently possible only in Unix environments). Output to  termi-
 
338
                 nal  is  normally automatically flushed by the operating sys-
 
339
                 tem. This option can be useful when the input  or  output  is
 
340
                 attached  to a pipe and you do not want pcregrep to buffer up
 
341
                 large amounts of data. However, its use will  affect  perfor-
330
342
                 mance, and the -M (multiline) option ceases to work.
331
343
 
332
344
       --line-offsets
333
 
                 Instead of showing lines or parts of lines that  match,  show
 
345
                 Instead  of  showing lines or parts of lines that match, show
334
346
                 each match as a line number, the offset from the start of the
335
 
                 line, and a length. The line number is terminated by a  colon
336
 
                 (as  usual; see the -n option), and the offset and length are
337
 
                 separated by a comma. In this  mode,  no  context  is  shown.
338
 
                 That  is, the -A, -B, and -C options are ignored. If there is
339
 
                 more than one match in a line, each of them  is  shown  sepa-
 
347
                 line,  and a length. The line number is terminated by a colon
 
348
                 (as usual; see the -n option), and the offset and length  are
 
349
                 separated  by  a  comma.  In  this mode, no context is shown.
 
350
                 That is, the -A, -B, and -C options are ignored. If there  is
 
351
                 more  than  one  match in a line, each of them is shown sepa-
340
352
                 rately. This option is mutually exclusive with --file-offsets
341
353
                 and --only-matching.
342
354
 
343
355
       --locale=locale-name
344
 
                 This option specifies a locale to be used for pattern  match-
345
 
                 ing.  It  overrides the value in the LC_ALL or LC_CTYPE envi-
346
 
                 ronment variables.  If  no  locale  is  specified,  the  PCRE
347
 
                 library's  default (usually the "C" locale) is used. There is
 
356
                 This  option specifies a locale to be used for pattern match-
 
357
                 ing. It overrides the value in the LC_ALL or  LC_CTYPE  envi-
 
358
                 ronment  variables.  If  no  locale  is  specified,  the PCRE
 
359
                 library's default (usually the "C" locale) is used. There  is
348
360
                 no short form for this option.
349
361
 
350
362
       --match-limit=number
351
 
                 Processing some regular expression  patterns  can  require  a
352
 
                 very  large amount of memory, leading in some cases to a pro-
353
 
                 gram crash if not enough is available.   Other  patterns  may
354
 
                 take  a  very  long  time to search for all possible matching
355
 
                 strings. The pcre_exec() function that is called by  pcregrep
356
 
                 to  do  the  matching  has  two parameters that can limit the
 
363
                 Processing  some  regular  expression  patterns can require a
 
364
                 very large amount of memory, leading in some cases to a  pro-
 
365
                 gram  crash  if  not enough is available.  Other patterns may
 
366
                 take a very long time to search  for  all  possible  matching
 
367
                 strings.  The pcre_exec() function that is called by pcregrep
 
368
                 to do the matching has two  parameters  that  can  limit  the
357
369
                 resources that it uses.
358
370
 
359
 
                 The  --match-limit  option  provides  a  means  of   limiting
 
371
                 The   --match-limit  option  provides  a  means  of  limiting
360
372
                 resource usage when processing patterns that are not going to
361
373
                 match, but which have a very large number of possibilities in
362
 
                 their  search  trees.  The  classic example is a pattern that
363
 
                 uses nested unlimited repeats. Internally, PCRE uses a  func-
364
 
                 tion  called  match()  which  it  calls repeatedly (sometimes
365
 
                 recursively). The limit set by --match-limit  is  imposed  on
366
 
                 the  number  of times this function is called during a match,
367
 
                 which has the effect of limiting the amount  of  backtracking
 
374
                 their search trees. The classic example  is  a  pattern  that
 
375
                 uses  nested unlimited repeats. Internally, PCRE uses a func-
 
376
                 tion called match()  which  it  calls  repeatedly  (sometimes
 
377
                 recursively).  The  limit  set by --match-limit is imposed on
 
378
                 the number of times this function is called during  a  match,
 
379
                 which  has  the effect of limiting the amount of backtracking
368
380
                 that can take place.
369
381
 
370
382
                 The --recursion-limit option is similar to --match-limit, but
371
383
                 instead of limiting the total number of times that match() is
372
384
                 called, it limits the depth of recursive calls, which in turn
373
 
                 limits the amount of memory that can be used.  The  recursion
374
 
                 depth  is  a  smaller  number than the total number of calls,
 
385
                 limits  the  amount of memory that can be used. The recursion
 
386
                 depth is a smaller number than the  total  number  of  calls,
375
387
                 because not all calls to match() are recursive. This limit is
376
388
                 of use only if it is set smaller than --match-limit.
377
389
 
378
 
                 There  are no short forms for these options. The default set-
379
 
                 tings are specified when the PCRE library is  compiled,  with
 
390
                 There are no short forms for these options. The default  set-
 
391
                 tings  are  specified when the PCRE library is compiled, with
380
392
                 the default default being 10 million.
381
393
 
382
394
       -M, --multiline
383
 
                 Allow  patterns to match more than one line. When this option
 
395
                 Allow patterns to match more than one line. When this  option
384
396
                 is given, patterns may usefully contain literal newline char-
385
 
                 acters  and  internal  occurrences of ^ and $ characters. The
386
 
                 output for a successful match may consist of  more  than  one
387
 
                 line,  the last of which is the one in which the match ended.
 
397
                 acters and internal occurrences of ^ and  $  characters.  The
 
398
                 output  for  a  successful match may consist of more than one
 
399
                 line, the last of which is the one in which the match  ended.
388
400
                 If the matched string ends with a newline sequence the output
389
401
                 ends at the end of that line.
390
402
 
391
 
                 When  this option is set, the PCRE library is called in "mul-
392
 
                 tiline" mode.  There is a limit to the number of  lines  that
393
 
                 can  be matched, imposed by the way that pcregrep buffers the
394
 
                 input file as it scans it. However, pcregrep ensures that  at
 
403
                 When this option is set, the PCRE library is called in  "mul-
 
404
                 tiline"  mode.   There is a limit to the number of lines that
 
405
                 can be matched, imposed by the way that pcregrep buffers  the
 
406
                 input  file as it scans it. However, pcregrep ensures that at
395
407
                 least 8K characters or the rest of the document (whichever is
396
 
                 the shorter) are available for forward  matching,  and  simi-
 
408
                 the  shorter)  are  available for forward matching, and simi-
397
409
                 larly the previous 8K characters (or all the previous charac-
398
 
                 ters, if fewer than 8K) are guaranteed to  be  available  for
399
 
                 lookbehind  assertions.  This option does not work when input
 
410
                 ters,  if  fewer  than 8K) are guaranteed to be available for
 
411
                 lookbehind assertions. This option does not work  when  input
400
412
                 is read line by line (see --line-buffered.)
401
413
 
402
414
       -N newline-type, --newline=newline-type
403
 
                 The PCRE library  supports  five  different  conventions  for
404
 
                 indicating  the  ends of lines. They are the single-character
405
 
                 sequences CR (carriage return) and LF  (linefeed),  the  two-
406
 
                 character  sequence CRLF, an "anycrlf" convention, which rec-
407
 
                 ognizes any of the preceding three types, and an  "any"  con-
 
415
                 The  PCRE  library  supports  five  different conventions for
 
416
                 indicating the ends of lines. They are  the  single-character
 
417
                 sequences  CR  (carriage  return) and LF (linefeed), the two-
 
418
                 character sequence CRLF, an "anycrlf" convention, which  rec-
 
419
                 ognizes  any  of the preceding three types, and an "any" con-
408
420
                 vention, in which any Unicode line ending sequence is assumed
409
 
                 to end a line. The Unicode sequences are the three just  men-
410
 
                 tioned,   plus  VT  (vertical  tab,  U+000B),  FF  (formfeed,
411
 
                 U+000C),  NEL  (next  line,  U+0085),  LS  (line   separator,
 
421
                 to  end a line. The Unicode sequences are the three just men-
 
422
                 tioned, plus  VT  (vertical  tab,  U+000B),  FF  (form  feed,
 
423
                 U+000C),   NEL  (next  line,  U+0085),  LS  (line  separator,
412
424
                 U+2028), and PS (paragraph separator, U+2029).
413
425
 
414
426
                 When  the  PCRE  library  is  built,  a  default  line-ending
415
 
                 sequence  is  specified.   This  is  normally  the   standard
 
427
                 sequence   is  specified.   This  is  normally  the  standard
416
428
                 sequence for the operating system. Unless otherwise specified
417
 
                 by this option, pcregrep uses  the  library's  default.   The
 
429
                 by  this  option,  pcregrep  uses the library's default.  The
418
430
                 possible values for this option are CR, LF, CRLF, ANYCRLF, or
419
 
                 ANY. This makes it possible to use  pcregrep  on  files  that
420
 
                 have  come  from  other environments without having to modify
421
 
                 their line endings. If the data that is  being  scanned  does
422
 
                 not  agree  with  the convention set by this option, pcregrep
 
431
                 ANY.  This  makes  it  possible to use pcregrep on files that
 
432
                 have come from other environments without  having  to  modify
 
433
                 their  line  endings.  If the data that is being scanned does
 
434
                 not agree with the convention set by  this  option,  pcregrep
423
435
                 may behave in strange ways.
424
436
 
425
437
       -n, --line-number
426
438
                 Precede each output line by its line number in the file, fol-
427
 
                 lowed  by  a colon for matching lines or a hyphen for context
428
 
                 lines. If the filename is also being output, it precedes  the
 
439
                 lowed by a colon for matching lines or a hyphen  for  context
 
440
                 lines.  If the filename is also being output, it precedes the
429
441
                 line number. This option is forced if --line-offsets is used.
430
442
 
 
443
       --no-jit  If the PCRE library is built with  support  for  just-in-time
 
444
                 compiling  (which speeds up matching), pcregrep automatically
 
445
                 makes use of this, unless it was explicitly disabled at build
 
446
                 time.  This  option  can be used to disable the use of JIT at
 
447
                 run time. It is provided for testing and working round  prob-
 
448
                 lems.  It should never be needed in normal use.
 
449
 
431
450
       -o, --only-matching
432
451
                 Show only the part of the line that matched a pattern instead
433
452
                 of the whole line. In this mode, no context  is  shown.  That
587
606
DIAGNOSTICS
588
607
 
589
608
       Exit status is 0 if any matches were found, 1 if no matches were found,
590
 
       and  2 for syntax errors and non-existent or inacessible files (even if
591
 
       matches were found in other files) or too many matching  errors.  Using
592
 
       the  -s  option to suppress error messages about inaccessble files does
593
 
       not affect the return code.
 
609
       and  2  for syntax errors, overlong lines, non-existent or inaccessible
 
610
       files (even if matches were found in other files) or too many  matching
 
611
       errors. Using the -s option to suppress error messages about inaccessi-
 
612
       ble files does not affect the return code.
594
613
 
595
614
 
596
615
SEE ALSO
607
626
 
608
627
REVISION
609
628
 
610
 
       Last updated: 14 January 2011
 
629
       Last updated: 06 September 2011
611
630
       Copyright (c) 1997-2011 University of Cambridge.