/[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 55 by nigel, Sat Feb 24 21:39:46 2007 UTC revision 75 by nigel, Sat Feb 24 21:40:37 2007 UTC
# Line 1  Line 1 
1  NAME  PCREGREP(1)                                                        PCREGREP(1)
      pcregrep - a grep with Perl-compatible regular expressions.  
2    
3    
4    
5  SYNOPSIS  NAME
6       pcregrep [-Vcfhilnrsvx] pattern [file] ...         pcregrep - a grep with Perl-compatible regular expressions.
7    
8    SYNOPSIS
9           pcregrep [-Vcfhilnrsuvx] [long options] [pattern] [file1 file2 ...]
10    
11    
12  DESCRIPTION  DESCRIPTION
      pcregrep searches files for character patterns, in the  same  
      way  as other grep commands do, but it uses the PCRE regular  
      expression library to support patterns that  are  compatible  
      with  the  regular  expressions of Perl 5. See pcre(3) for a  
      full description of syntax and semantics.  
   
      If no files  are  specified,  pcregrep  reads  the  standard  
      input.  By  default,  each  line that matches the pattern is  
      copied to the standard output, and if there is more than one  
      file,  the  file name is printed before each line of output.  
      However, there are options  that  can  change  how  pcregrep  
      behaves.  
   
      Lines are limited to BUFSIZ characters. BUFSIZ is defined in  
      <stdio.h>.  The newline character is removed from the end of  
      each line before it is matched against the pattern.  
13    
14           pcregrep  searches  files  for  character  patterns, in the same way as
15           other grep commands do, but it uses the PCRE regular expression library
16           to support patterns that are compatible with the regular expressions of
17           Perl 5. See pcrepattern for a full description of syntax and  semantics
18           of the regular expressions that PCRE supports.
19    
20           A pattern must be specified on the command line unless the -f option is
21           used (see below).
22    
23           If no files are  specified,  pcregrep  reads  the  standard  input.  By
24           default,  each  line that matches the pattern is copied to the standard
25           output, and if there is more than one file, the file  name  is  printed
26           before  each line of output. However, there are options that can change
27           how pcregrep behaves.
28    
29           Lines are limited to BUFSIZ characters. BUFSIZ is defined in <stdio.h>.
30           The newline character is removed from the end of each line before it is
31           matched against the pattern.
32    
33    
34  OPTIONS  OPTIONS
      -V        Write the version number of the PCRE library being  
                used to the standard error stream.  
35    
      -c        Do not print individual lines; instead just  print  
                a  count  of the number of lines that would other-  
                wise have  been  printed.  If  several  files  are  
                given, a count is printed for each of them.  
   
        versity of Cambridge for use on Unix systems connected  to  
                       the  Internet.   It   is  freely  available  
                under the terms of  
                       the GNU General Public Licence. In style it  
                is similar  to  
                       Smail  3,  but  its   facilities  are  more  
                extensive, and in  
                       particular it has  some  defences   against  
                mail  bombs  and  
                       unsolicited  junk  mail,  in  the  form  of  
                options for refusing  
                       messages from particular  hosts,  networks,  
                or senders.  
   
                       Exim's command  line  takes  the   standard  
   
                Unix  form  of  a  
                       sequence  of  options, each starting with a  
                hyphen  charac-ffilename  Read  patterns  from the  
                file, one per line, and match all patterns against  
                each  line.  There  is  a maximum of 100 patterns.  
                Trailing white space is removed, and  blank  lines  
                are  ignored.  An  empty file contains no patterns  
                and therefore matches nothing.  
   
      -h        Suppress printing of filenames when searching mul-  
                tiple files.  
   
      -i        Ignore upper/lower case distinctions  during  com-  
                parisons.  
   
      -l        Instead of printing lines  from  the  files,  just  
                print the names of the files containing lines that  
                would have been printed. Each file name is printed  
                once, on a separate line.  
   
      -n        Precede each line by its line number in the file.  
   
      -r        If any file is a directory, recursively  scan  the  
                files  it  contains.  Without  -r  a  directory is  
                scanned as a normal file.  
   
      -s        Work silently, that  is,  display  nothing  except  
                error messages.  The exit status indicates whether  
                any matches were found.  
   
      -v        Invert the sense of the match, so that lines which  
                do not match the pattern are now the ones that are  
                found.  
   
      -x        Force the pattern to be anchored  (it  must  start  
                matching  at  the  beginning  of  the line) and in  
                addition, require it to  match  the  entire  line.  
                This is equivalent to having ^ and $ characters at  
                the start and end of each  alternative  branch  in  
                the regular expression.  
   
   
   
 SEE ALSO  
      pcre(3), Perl 5 documentation  
36    
37           -V        Write the version number of the PCRE library  being  used  to
38                     the standard error stream.
39    
40           -c        Do  not print individual lines; instead just print a count of
41                     the number of lines that would otherwise have  been  printed.
42                     If  several  files  are given, a count is printed for each of
43                     them.
44    
45           -ffilename
46                     Read a number of patterns from the file, one  per  line,  and
47                     match  all of them against each line of input. A line is out-
48                     put if any of the patterns match it.  When  -f  is  used,  no
49                     pattern  is  taken  from  the command line; all arguments are
50                     treated as file names. There is a maximum  of  100  patterns.
51                     Trailing white space is removed, and blank lines are ignored.
52                     An empty file contains  no  patterns  and  therefore  matches
53                     nothing.
54    
55           -h        Suppress printing of filenames when searching multiple files.
56    
57           -i        Ignore upper/lower case distinctions during comparisons.
58    
59           -l        Instead of printing lines from  the  files,  just  print  the
60                     names  of  the  files  containing  lines that would have been
61                     printed. Each file name is printed once, on a separate  line.
62    
63           -n        Precede each line by its line number in the file.
64    
65           -r        If  any  file  is  a directory, recursively scan the files it
66                     contains. Without -r a directory is scanned as a normal file.
67    
68           -s        Work  silently,  that  is,  display nothing except error mes-
69                     sages.  The exit status indicates whether  any  matches  were
70                     found.
71    
72           -u        Operate  in UTF-8 mode. This option is available only if PCRE
73                     has been compiled with UTF-8 support. Both  the  pattern  and
74                     each  subject line must be valid strings of UTF-8 characters.
75    
76           -v        Invert the sense of the match, so that  lines  which  do  not
77                     match the pattern are now the ones that are found.
78    
79           -x        Force  the  pattern to be anchored (it must start matching at
80                     the beginning of the line) and in  addition,  require  it  to
81                     match  the  entire line. This is equivalent to having ^ and $
82                     characters at the start and end of each alternative branch in
83                     the regular expression.
84    
85    
86    LONG OPTIONS
87    
88           Long  forms  of all the options are available, as in GNU grep. They are
89           shown in the following table:
90    
91             -c   --count
92             -h   --no-filename
93             -i   --ignore-case
94             -l   --files-with-matches
95             -n   --line-number
96             -r   --recursive
97             -s   --no-messages
98             -u   --utf-8
99             -V   --version
100             -v   --invert-match
101             -x   --line-regex
102             -x   --line-regexp
103    
104           In addition, --file=filename is equivalent to  -ffilename,  and  --help
105           shows the list of options and then exits.
106    
107    
108  DIAGNOSTICS  DIAGNOSTICS
      Exit status is 0 if any matches were found, 1 if no  matches  
      were  found,  and  2  for syntax errors or inacessible files  
      (even if matches were found).  
109    
110           Exit status is 0 if any matches were found, 1 if no matches were found,
111           and 2 for syntax errors or inacessible  files  (even  if  matches  were
112           found).
113    
114    
115  AUTHOR  AUTHOR
      Philip Hazel <ph10@cam.ac.uk>  
116    
117       Last updated: 15 August 2001         Philip Hazel <ph10@cam.ac.uk>
118       Copyright (c) 1997-2001 University of Cambridge.         University Computing Service
119           Cambridge CB2 3QG, England.
120    
121    Last updated: 09 September 2004
122    Copyright (c) 1997-2004 University of Cambridge.

Legend:
Removed from v.55  
changed lines
  Added in v.75

  ViewVC Help
Powered by ViewVC 1.1.5