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

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

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

revision 76 by nigel, Sat Feb 24 21:40:37 2007 UTC revision 77 by nigel, Sat Feb 24 21:40:45 2007 UTC
# Line 2  Line 2 
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 [-Vcfhilnrsuvx] [long options] [pattern] [file1 file2 ...]  .B pcregrep [options] [long options] [pattern] [file1 file2 ...]
6  .  .
7  .SH DESCRIPTION  .SH DESCRIPTION
8  .rs  .rs
# Line 19  PCRE supports. Line 19  PCRE supports.
19  A pattern must be specified on the command line unless the \fB-f\fP option is  A pattern must be specified on the command line unless the \fB-f\fP option is
20  used (see below).  used (see below).
21  .P  .P
22  If no files are specified, \fBpcregrep\fP reads the standard input. By default,  If no files are specified, \fBpcregrep\fP reads the standard input. The
23  each line that matches the pattern is copied to the standard output, and if  standard input can also be referenced by a name consisting of a single hyphen.
24  there is more than one file, the file name is printed before each line of  For example:
25  output. However, there are options that can change how \fBpcregrep\fP behaves.  .sp
26      pcregrep some-pattern /file1 - /file3
27    .sp
28    By default, each line that matches the pattern is copied to the standard
29    output, and if there is more than one file, the file name is printed before
30    each line of output. However, there are options that can change how
31    \fBpcregrep\fP behaves. In particular, the \fB-M\fP option makes it possible to
32    search for patterns that span line boundaries.
33  .P  .P
34  Lines are limited to BUFSIZ characters. BUFSIZ is defined in \fB<stdio.h>\fP.  Patterns are limited to 8K or BUFSIZ characters, whichever is the greater.
35  The newline character is removed from the end of each line before it is matched  BUFSIZ is defined in \fB<stdio.h>\fP.
 against the pattern.  
36  .  .
37  .SH OPTIONS  .SH OPTIONS
38  .rs  .rs
 .sp  
39  .TP 10  .TP 10
40  \fB-V\fP  \fB--\fP
41  Write the version number of the PCRE library being used to the standard error  This terminate the list of options. It is useful if the next item on the
42  stream.  command line starts with a hyphen, but is not an option.
43    .TP
44    \fB-A\fP \fInumber\fP
45    Print \fInumber\fP lines of context after each matching line. If file names
46    and/or line numbers are being printed, a hyphen separator is used instead of a
47    colon for the context lines. A line containing "--" is printed between each
48    group of lines, unless they are in fact contiguous in the input file. The value
49    of \fInumber\fP is expected to be relatively small. However, \fBpcregrep\fP
50    guarantees to have up to 8K of following text available for context printing.
51    .TP
52    \fB-B\fP \fInumber\fP
53    Print \fInumber\fP lines of context before each matching line. If file names
54    and/or line numbers are being printed, a hyphen separator is used instead of a
55    colon for the context lines. A line containing "--" is printed between each
56    group of lines, unless they are in fact contiguous in the input file. The value
57    of \fInumber\fP is expected to be relatively small. However, \fBpcregrep\fP
58    guarantees to have up to 8K of preceding text available for context printing.
59    .TP
60    \fB-C\fP \fInumber\fP
61    Print \fInumber\fP lines of context both before and after each matching line.
62    This is equivalent to setting both \fB-A\fP and \fB-B\fP to the same value.
63  .TP  .TP
64  \fB-c\fP  \fB-c\fP
65  Do not print individual lines; instead just print a count of the number of  Do not print individual lines; instead just print a count of the number of
66  lines that would otherwise have been printed. If several files are given, a  lines that would otherwise have been printed. If several files are given, a
67  count is printed for each of them.  count is printed for each of them.
68  .TP  .TP
69    \fB--exclude\fP=\fIpattern\fP
70    When \fBpcregrep\fP is searching the files in a directory as a consequence of
71    the \fB-r\fP (recursive search) option, any files whose names match the pattern
72    are excluded. The pattern is a PCRE regular expression. If a file name matches
73    both \fB--include\fP and \fB--exclude\fP, it is excluded. There is no short
74    form for this option.
75    .TP
76  \fB-f\fP\fIfilename\fP  \fB-f\fP\fIfilename\fP
77  Read a number of patterns from the file, one per line, and match all of them  Read a number of patterns from the file, one per line, and match all of them
78  against each line of input. A line is output if any of the patterns match it.  against each line of input. A line is output if any of the patterns match it.
# Line 55  Suppress printing of filenames when sear Line 87  Suppress printing of filenames when sear
87  \fB-i\fP  \fB-i\fP
88  Ignore upper/lower case distinctions during comparisons.  Ignore upper/lower case distinctions during comparisons.
89  .TP  .TP
90    \fB--include\fP=\fIpattern\fP
91    When \fBpcregrep\fP is searching the files in a directory as a consequence of
92    the \fB-r\fP (recursive search) option, only files whose names match the
93    pattern are included. The pattern is a PCRE regular expression. If a file name
94    matches both \fB--include\fP and \fB--exclude\fP, it is excluded. There is no
95    short form for this option.
96    .TP
97    \fB-L\fP
98    Instead of printing lines from the files, just print the names of the files
99    that do not contain any lines that would have been printed. Each file name is
100    printed once, on a separate line.
101    .TP
102  \fB-l\fP  \fB-l\fP
103  Instead of printing lines from the files, just print the names of the files  Instead of printing lines from the files, just print the names of the files
104  containing lines that would have been printed. Each file name is printed  containing lines that would have been printed. Each file name is printed
105  once, on a separate line.  once, on a separate line.
106  .TP  .TP
107    \fB--label\fP=\fIname\fP
108    This option supplies a name to be used for the standard input when file names
109    are being printed. If not supplied, "(standard input)" is used. There is no
110    short form for this option.
111    .TP
112    \fB-M\fP
113    Allow patterns to match more than one line. When this option is given, patterns
114    may usefully contain literal newline characters and internal occurrences of ^
115    and $ characters. The output for any one match may consist of more than one
116    line. When this option is set, the PCRE library is called in "multiline" mode.
117    There is a limit to the number of lines that can be matched, imposed by the way
118    that \fBpcregrep\fP buffers the input file as it scans it. However,
119    \fBpcregrep\fP ensures that at least 8K characters or the rest of the document
120    (whichever is the shorter) are available for forward matching, and similarly
121    the previous 8K characters (or all the previous characters, if fewer than 8K)
122    are guaranteed to be available for lookbehind assertions.
123    .TP
124  \fB-n\fP  \fB-n\fP
125  Precede each line by its line number in the file.  Precede each line by its line number in the file.
126  .TP  .TP
127    \fB-q\fP
128    Work quietly, that is, display nothing except error messages.
129    The exit status indicates whether or not any matches were found.
130    .TP
131  \fB-r\fP  \fB-r\fP
132  If any file is a directory, recursively scan the files it contains. Without  If any given path is a directory, recursively scan the files it contains,
133    taking note of any \fB--include\fP and \fB--exclude\fP settings. Without
134  \fB-r\fP a directory is scanned as a normal file.  \fB-r\fP a directory is scanned as a normal file.
135  .TP  .TP
136  \fB-s\fP  \fB-s\fP
137  Work silently, that is, display nothing except error messages.  Suppress error messages about non-existent or unreadable files. Such files are
138  The exit status indicates whether any matches were found.  quietly skipped. However, the return code is still 2, even if matches were
139    found in other files.
140  .TP  .TP
141  \fB-u\fP  \fB-u\fP
142  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
143  with UTF-8 support. Both the pattern and each subject line must be valid  with UTF-8 support. Both the pattern and each subject line must be valid
144  strings of UTF-8 characters.  strings of UTF-8 characters.
145  .TP  .TP
146    \fB-V\fP
147    Write the version numbers of \fBpcregrep\fP and the PCRE library that is being
148    used to the standard error stream.
149    .TP
150  \fB-v\fP  \fB-v\fP
151  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 the
152  pattern are now the ones that are found.  pattern are the ones that are found.
153    .TP
154    \fB-w\fP
155    Force the pattern to match only whole words. This is equivalent to having \eb
156    at the start and end of the pattern.
157  .TP  .TP
158  \fB-x\fP  \fB-x\fP
159  Force the pattern to be anchored (it must start matching at the beginning of  Force the pattern to be anchored (it must start matching at the beginning of
# Line 92  alternative branch in the regular expres Line 167  alternative branch in the regular expres
167  Long forms of all the options are available, as in GNU grep. They are shown in  Long forms of all the options are available, as in GNU grep. They are shown in
168  the following table:  the following table:
169  .sp  .sp
170      -A   --after-context
171      -B   --before-context
172      -C   --context
173    -c   --count    -c   --count
174           --exclude (no short form)
175      -f   --file
176    -h   --no-filename    -h   --no-filename
177           --help (no short form)
178    -i   --ignore-case    -i   --ignore-case
179           --include (no short form)
180      -L   --files-without-match
181    -l   --files-with-matches    -l   --files-with-matches
182           --label (no short form)
183    -n   --line-number    -n   --line-number
184    -r   --recursive    -r   --recursive
185      -q   --quiet
186    -s   --no-messages    -s   --no-messages
187    -u   --utf-8    -u   --utf-8
188    -V   --version    -V   --version
189    -v   --invert-match    -v   --invert-match
190    -x   --line-regex    -x   --line-regex
191    -x   --line-regexp    -x   --line-regexp
192    .
193    .SH "OPTIONS WITH DATA"
194    .rs
195    .sp
196    There are four different ways in which an option with data can be specified.
197    If a short form option is used, the data may follow immediately, or in the next
198    command line item. For example:
199    .sp
200      -f/some/file
201      -f /some/file
202    .sp
203    If a long form option is used, the data may appear in the same command line
204    item, separated by an = character, or it may appear in the next command line
205    item. For example:
206    .sp
207      --file=/some/file
208      --file /some/file
209  .sp  .sp
 In addition, --file=\fIfilename\fP is equivalent to -f\fIfilename\fP, and  
 --help shows the list of options and then exits.  
210  .  .
211  .SH DIAGNOSTICS  .SH DIAGNOSTICS
212  .rs  .rs
213  .sp  .sp
214  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
215  for syntax errors or inacessible files (even if matches were found).  for syntax errors and non-existent or inacessible files (even if matches were
216    found in other files). Using the \fB-s\fP option to suppress error messages
217    about inaccessble files does not affect the return code.
218  .  .
219  .  .
220  .SH AUTHOR  .SH AUTHOR
221  .rs  .rs
222  .sp  .sp
223  Philip Hazel <ph10@cam.ac.uk>  Philip Hazel
224  .br  .br
225  University Computing Service  University Computing Service
226  .br  .br
227  Cambridge CB2 3QG, England.  Cambridge CB2 3QG, England.
228  .P  .P
229  .in 0  .in 0
230  Last updated: 09 September 2004  Last updated: 16 May 2005
231  .br  .br
232  Copyright (c) 1997-2004 University of Cambridge.  Copyright (c) 1997-2005 University of Cambridge.

Legend:
Removed from v.76  
changed lines
  Added in v.77

webmaster@exim.org
ViewVC Help
Powered by ViewVC 1.1.12