/[pcre]/code/trunk/doc/pcregrep.txt
ViewVC logotype

Diff of /code/trunk/doc/pcregrep.txt

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 654 by ph10, Tue Aug 2 11:00:40 2011 UTC revision 691 by ph10, Sun Sep 11 14:31:21 2011 UTC
# Line 440  OPTIONS Line 440  OPTIONS
440                   lines.  If the filename is also being output, it precedes the                   lines.  If the filename is also being output, it precedes the
441                   line number. This option is forced if --line-offsets is used.                   line number. This option is forced if --line-offsets is used.
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    
450         -o, --only-matching         -o, --only-matching
451                   Show only the part of the line that matched a pattern instead                   Show only the part of the line that matched a pattern instead
452                   of  the  whole  line. In this mode, no context is shown. That                   of the whole line. In this mode, no context  is  shown.  That
453                   is, the -A, -B, and -C options are ignored. If there is  more                   is,  the -A, -B, and -C options are ignored. If there is more
454                   than  one  match in a line, each of them is shown separately.                   than one match in a line, each of them is  shown  separately.
455                   If -o is combined with -v (invert the sense of the  match  to                   If  -o  is combined with -v (invert the sense of the match to
456                   find  non-matching  lines),  no  output is generated, but the                   find non-matching lines), no output  is  generated,  but  the
457                   return code is set appropriately. If the matched  portion  of                   return  code  is set appropriately. If the matched portion of
458                   the  line is empty, nothing is output unless the file name or                   the line is empty, nothing is output unless the file name  or
459                   line number are being printed, in which case they  are  shown                   line  number  are being printed, in which case they are shown
460                   on an otherwise empty line. This option is mutually exclusive                   on an otherwise empty line. This option is mutually exclusive
461                   with --file-offsets and --line-offsets.                   with --file-offsets and --line-offsets.
462    
463         -onumber, --only-matching=number         -onumber, --only-matching=number
464                   Show only the part of the line  that  matched  the  capturing                   Show  only  the  part  of the line that matched the capturing
465                   parentheses of the given number. Up to 32 capturing parenthe-                   parentheses of the given number. Up to 32 capturing parenthe-
466                   ses are supported. Because these options can be given without                   ses are supported. Because these options can be given without
467                   an  argument  (see above), if an argument is present, it must                   an argument (see above), if an argument is present,  it  must
468                   be given in the same shell item, for example, -o3 or  --only-                   be  given in the same shell item, for example, -o3 or --only-
469                   matching=2.  The  comments  given  for  the non-argument case                   matching=2. The comments  given  for  the  non-argument  case
470                   above also apply to this case.  If  the  specified  capturing                   above  also  apply  to  this case. If the specified capturing
471                   parentheses  do  not exist in the pattern, or were not set in                   parentheses do not exist in the pattern, or were not  set  in
472                   the match, nothing is output unless the  file  name  or  line                   the  match,  nothing  is  output unless the file name or line
473                   number are being printed.                   number are being printed.
474    
475         -q, --quiet         -q, --quiet
476                   Work quietly, that is, display nothing except error messages.                   Work quietly, that is, display nothing except error messages.
477                   The exit status indicates whether or  not  any  matches  were                   The  exit  status  indicates  whether or not any matches were
478                   found.                   found.
479    
480         -r, --recursive         -r, --recursive
481                   If  any given path is a directory, recursively scan the files                   If any given path is a directory, recursively scan the  files
482                   it contains, taking note of any --include and --exclude  set-                   it  contains, taking note of any --include and --exclude set-
483                   tings.  By  default, a directory is read as a normal file; in                   tings. By default, a directory is read as a normal  file;  in
484                   some operating systems this gives an  immediate  end-of-file.                   some  operating  systems this gives an immediate end-of-file.
485                   This  option  is  a  shorthand  for  setting the -d option to                   This option is a shorthand  for  setting  the  -d  option  to
486                   "recurse".                   "recurse".
487    
488         --recursion-limit=number         --recursion-limit=number
489                   See --match-limit above.                   See --match-limit above.
490    
491         -s, --no-messages         -s, --no-messages
492                   Suppress error  messages  about  non-existent  or  unreadable                   Suppress  error  messages  about  non-existent  or unreadable
493                   files.  Such  files  are quietly skipped. However, the return                   files. Such files are quietly skipped.  However,  the  return
494                   code is still 2, even if matches were found in other files.                   code is still 2, even if matches were found in other files.
495    
496         -u, --utf-8         -u, --utf-8
497                   Operate in UTF-8 mode. This option is available only if  PCRE                   Operate  in UTF-8 mode. This option is available only if PCRE
498                   has  been compiled with UTF-8 support. Both patterns and sub-                   has been compiled with UTF-8 support. Both patterns and  sub-
499                   ject lines must be valid strings of UTF-8 characters.                   ject lines must be valid strings of UTF-8 characters.
500    
501         -V, --version         -V, --version
502                   Write the version numbers of pcregrep and  the  PCRE  library                   Write  the  version  numbers of pcregrep and the PCRE library
503                   that is being used to the standard error stream.                   that is being used to the standard error stream.
504    
505         -v, --invert-match         -v, --invert-match
506                   Invert  the  sense  of  the match, so that lines which do not                   Invert the sense of the match, so that  lines  which  do  not
507                   match any of the patterns are the ones that are found.                   match any of the patterns are the ones that are found.
508    
509         -w, --word-regex, --word-regexp         -w, --word-regex, --word-regexp
# Line 504  OPTIONS Line 511  OPTIONS
511                   lent to having \b at the start and end of the pattern.                   lent to having \b at the start and end of the pattern.
512    
513         -x, --line-regex, --line-regexp         -x, --line-regex, --line-regexp
514                   Force  the  patterns to be anchored (each must start matching                   Force the patterns to be anchored (each must  start  matching
515                   at the beginning of a line) and in addition, require them  to                   at  the beginning of a line) and in addition, require them to
516                   match  entire  lines.  This  is  equivalent to having ^ and $                   match entire lines. This is equivalent  to  having  ^  and  $
517                   characters at the start and end of each alternative branch in                   characters at the start and end of each alternative branch in
518                   every pattern.                   every pattern.
519    
520    
521  ENVIRONMENT VARIABLES  ENVIRONMENT VARIABLES
522    
523         The  environment  variables  LC_ALL  and LC_CTYPE are examined, in that         The environment variables LC_ALL and LC_CTYPE  are  examined,  in  that
524         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
525         overridden  by  the  --locale  option.  If  no  locale is set, the PCRE         overridden by the --locale option.  If  no  locale  is  set,  the  PCRE
526         library's default (usually the "C" locale) is used.         library's default (usually the "C" locale) is used.
527    
528    
529  NEWLINES  NEWLINES
530    
531         The -N (--newline) option allows pcregrep to scan files with  different         The  -N (--newline) option allows pcregrep to scan files with different
532         newline  conventions  from  the  default.  However, the setting of this         newline conventions from the default.  However,  the  setting  of  this
533         option does not affect the way in which pcregrep writes information  to         option  does not affect the way in which pcregrep writes information to
534         the  standard  error  and  output streams. It uses the string "\n" in C         the standard error and output streams. It uses the  string  "\n"  in  C
535         printf() calls to indicate newlines, relying on the C  I/O  library  to         printf()  calls  to  indicate newlines, relying on the C I/O library to
536         convert  this  to  an  appropriate  sequence if the output is sent to a         convert this to an appropriate sequence if the  output  is  sent  to  a
537         file.         file.
538    
539    
540  OPTIONS COMPATIBILITY  OPTIONS COMPATIBILITY
541    
542         Many of the short and long forms of pcregrep's options are the same  as         Many  of the short and long forms of pcregrep's options are the same as
543         in  the  GNU  grep program (version 2.5.4). Any long option of the form         in the GNU grep program (version 2.5.4). Any long option  of  the  form
544         --xxx-regexp (GNU terminology) is also available as  --xxx-regex  (PCRE         --xxx-regexp  (GNU  terminology) is also available as --xxx-regex (PCRE
545         terminology).  However,  the --file-offsets, --include-dir, --line-off-         terminology). However, the --file-offsets,  --include-dir,  --line-off-
546         sets, --locale, --match-limit, -M, --multiline, -N, --newline, --recur-         sets, --locale, --match-limit, -M, --multiline, -N, --newline, --recur-
547         sion-limit, -u, and --utf-8 options are specific to pcregrep, as is the         sion-limit, -u, and --utf-8 options are specific to pcregrep, as is the
548         use of the --only-matching option with a capturing parentheses number.         use of the --only-matching option with a capturing parentheses number.
549    
550         Although most of the common options work the same way, a few  are  dif-         Although  most  of the common options work the same way, a few are dif-
551         ferent  in  pcregrep. For example, the --include option's argument is a         ferent in pcregrep. For example, the --include option's argument  is  a
552         glob for GNU grep, but a regular expression for pcregrep. If  both  the         glob  for  GNU grep, but a regular expression for pcregrep. If both the
553         -c  and  -l  options are given, GNU grep lists only file names, without         -c and -l options are given, GNU grep lists only  file  names,  without
554         counts, but pcregrep gives the counts.         counts, but pcregrep gives the counts.
555    
556    
557  OPTIONS WITH DATA  OPTIONS WITH DATA
558    
559         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-
560         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-
561         ately, or (with one exception) in the next command line item. For exam-         ately, or (with one exception) in the next command line item. For exam-
562         ple:         ple:
563    
564           -f/some/file           -f/some/file
565           -f /some/file           -f /some/file
566    
567         The  exception is the -o option, which may appear with or without data.         The exception is the -o option, which may appear with or without  data.
568         Because of this, if data is present, it must follow immediately in  the         Because  of this, if data is present, it must follow immediately in the
569         same item, for example -o3.         same item, for example -o3.
570    
571         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
572         line item, separated by an equals character, or (with  two  exceptions)         line  item,  separated by an equals character, or (with two exceptions)
573         it may appear in the next command line item. For example:         it may appear in the next command line item. For example:
574    
575           --file=/some/file           --file=/some/file
576           --file /some/file           --file /some/file
577    
578         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  ~
579         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
580         directory, you must separate the file name from the option, because the         directory, you must separate the file name from the option, because the
581         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.
582    
583         The exceptions to the above are the --colour (or --color)  and  --only-         The  exceptions  to the above are the --colour (or --color) and --only-
584         matching  options,  for  which  the  data  is optional. If one of these         matching options, for which the data  is  optional.  If  one  of  these
585         options does have data, it must be given in the first  form,  using  an         options  does  have  data, it must be given in the first form, using an
586         equals character. Otherwise pcregrep will assume that it has no data.         equals character. Otherwise pcregrep will assume that it has no data.
587    
588    
589  MATCHING ERRORS  MATCHING ERRORS
590    
591         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
592         time to fail to match certain lines.  Such  patterns  normally  involve         time  to  fail  to  match certain lines. Such patterns normally involve
593         nested  indefinite repeats, for example: (a+)*\d when matched against a         nested indefinite repeats, for example: (a+)*\d when matched against  a
594         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
595         resource  limit that causes it to abort in these circumstances. If this         resource limit that causes it to abort in these circumstances. If  this
596         happens, pcregrep outputs an error message and the line that caused the         happens, pcregrep outputs an error message and the line that caused the
597         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
598         errors, pcregrep gives up.         errors, pcregrep gives up.
599    
600         The --match-limit option of pcregrep can be used  to  set  the  overall         The  --match-limit  option  of  pcregrep can be used to set the overall
601         resource  limit; there is a second option called --recursion-limit that         resource limit; there is a second option called --recursion-limit  that
602         sets a limit on the amount of memory (usually stack) that is used  (see         sets  a limit on the amount of memory (usually stack) that is used (see
603         the discussion of these options above).         the discussion of these options above).
604    
605    
606  DIAGNOSTICS  DIAGNOSTICS
607    
608         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,
609         and 2 for syntax errors, overlong lines, non-existent  or  inaccessible         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         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-         errors. Using the -s option to suppress error messages about inaccessi-
612         ble files does not affect the return code.         ble files does not affect the return code.
613    
# Line 619  AUTHOR Line 626  AUTHOR
626    
627  REVISION  REVISION
628    
629         Last updated: 30 July 2011         Last updated: 06 September 2011
630         Copyright (c) 1997-2011 University of Cambridge.         Copyright (c) 1997-2011 University of Cambridge.

Legend:
Removed from v.654  
changed lines
  Added in v.691

webmaster@exim.org
ViewVC Help
Powered by ViewVC 1.1.12