1 |
<html>
|
2 |
<head>
|
3 |
<title>pcregrep specification</title>
|
4 |
</head>
|
5 |
<body bgcolor="#FFFFFF" text="#00005A" link="#0066FF" alink="#3399FF" vlink="#2222BB">
|
6 |
This HTML document has been generated automatically from the original man page.
|
7 |
If there is any nonsense in it, please consult the man page, in case the
|
8 |
conversion went wrong.<br>
|
9 |
<ul>
|
10 |
<li><a name="TOC1" href="#SEC1">SYNOPSIS</a>
|
11 |
<li><a name="TOC2" href="#SEC2">DESCRIPTION</a>
|
12 |
<li><a name="TOC3" href="#SEC3">OPTIONS</a>
|
13 |
<li><a name="TOC4" href="#SEC4">LONG OPTIONS</a>
|
14 |
<li><a name="TOC5" href="#SEC5">DIAGNOSTICS</a>
|
15 |
<li><a name="TOC6" href="#SEC6">AUTHOR</a>
|
16 |
</ul>
|
17 |
<br><a name="SEC1" href="#TOC1">SYNOPSIS</a><br>
|
18 |
<P>
|
19 |
<b>pcregrep [-Vcfhilnrsuvx] [long options] [pattern] [file1 file2 ...]</b>
|
20 |
</P>
|
21 |
<br><a name="SEC2" href="#TOC1">DESCRIPTION</a><br>
|
22 |
<P>
|
23 |
<b>pcregrep</b> searches files for character patterns, in the same way as other
|
24 |
grep commands do, but it uses the PCRE regular expression library to support
|
25 |
patterns that are compatible with the regular expressions of Perl 5. See
|
26 |
<a href="pcrepattern.html"><b>pcrepattern</b></a>
|
27 |
for a full description of syntax and semantics of the regular expressions that
|
28 |
PCRE supports.
|
29 |
</P>
|
30 |
<P>
|
31 |
A pattern must be specified on the command line unless the <b>-f</b> option is
|
32 |
used (see below).
|
33 |
</P>
|
34 |
<P>
|
35 |
If no files are specified, <b>pcregrep</b> reads the standard input. By default,
|
36 |
each line that matches the pattern is copied to the standard output, and if
|
37 |
there is more than one file, the file name is printed before each line of
|
38 |
output. However, there are options that can change how <b>pcregrep</b> behaves.
|
39 |
</P>
|
40 |
<P>
|
41 |
Lines are limited to BUFSIZ characters. BUFSIZ is defined in <b><stdio.h></b>.
|
42 |
The newline character is removed from the end of each line before it is matched
|
43 |
against the pattern.
|
44 |
</P>
|
45 |
<br><a name="SEC3" href="#TOC1">OPTIONS</a><br>
|
46 |
<P>
|
47 |
<b>-V</b>
|
48 |
Write the version number of the PCRE library being used to the standard error
|
49 |
stream.
|
50 |
</P>
|
51 |
<P>
|
52 |
<b>-c</b>
|
53 |
Do not print individual lines; instead just print a count of the number of
|
54 |
lines that would otherwise have been printed. If several files are given, a
|
55 |
count is printed for each of them.
|
56 |
</P>
|
57 |
<P>
|
58 |
<b>-f</b><i>filename</i>
|
59 |
Read a number of patterns from the file, one per line, and match all of them
|
60 |
against each line of input. A line is output if any of the patterns match it.
|
61 |
When <b>-f</b> is used, no pattern is taken from the command line; all arguments
|
62 |
are treated as file names. There is a maximum of 100 patterns. Trailing white
|
63 |
space is removed, and blank lines are ignored. An empty file contains no
|
64 |
patterns and therefore matches nothing.
|
65 |
</P>
|
66 |
<P>
|
67 |
<b>-h</b>
|
68 |
Suppress printing of filenames when searching multiple files.
|
69 |
</P>
|
70 |
<P>
|
71 |
<b>-i</b>
|
72 |
Ignore upper/lower case distinctions during comparisons.
|
73 |
</P>
|
74 |
<P>
|
75 |
<b>-l</b>
|
76 |
Instead of printing lines from the files, just print the names of the files
|
77 |
containing lines that would have been printed. Each file name is printed
|
78 |
once, on a separate line.
|
79 |
</P>
|
80 |
<P>
|
81 |
<b>-n</b>
|
82 |
Precede each line by its line number in the file.
|
83 |
</P>
|
84 |
<P>
|
85 |
<b>-r</b>
|
86 |
If any file is a directory, recursively scan the files it contains. Without
|
87 |
<b>-r</b> a directory is scanned as a normal file.
|
88 |
</P>
|
89 |
<P>
|
90 |
<b>-s</b>
|
91 |
Work silently, that is, display nothing except error messages.
|
92 |
The exit status indicates whether any matches were found.
|
93 |
</P>
|
94 |
<P>
|
95 |
<b>-u</b>
|
96 |
Operate in UTF-8 mode. This option is available only if PCRE has been compiled
|
97 |
with UTF-8 support. Both the pattern and each subject line are assumed to be
|
98 |
valid strings of UTF-8 characters.
|
99 |
</P>
|
100 |
<P>
|
101 |
<b>-v</b>
|
102 |
Invert the sense of the match, so that lines which do <i>not</i> match the
|
103 |
pattern are now the ones that are found.
|
104 |
</P>
|
105 |
<P>
|
106 |
<b>-x</b>
|
107 |
Force the pattern to be anchored (it must start matching at the beginning of
|
108 |
the line) and in addition, require it to match the entire line. This is
|
109 |
equivalent to having ^ and $ characters at the start and end of each
|
110 |
alternative branch in the regular expression.
|
111 |
</P>
|
112 |
<br><a name="SEC4" href="#TOC1">LONG OPTIONS</a><br>
|
113 |
<P>
|
114 |
Long forms of all the options are available, as in GNU grep. They are shown in
|
115 |
the following table:
|
116 |
</P>
|
117 |
<P>
|
118 |
<pre>
|
119 |
-c --count
|
120 |
-h --no-filename
|
121 |
-i --ignore-case
|
122 |
-l --files-with-matches
|
123 |
-n --line-number
|
124 |
-r --recursive
|
125 |
-s --no-messages
|
126 |
-u --utf-8
|
127 |
-V --version
|
128 |
-v --invert-match
|
129 |
-x --line-regex
|
130 |
-x --line-regexp
|
131 |
</PRE>
|
132 |
</P>
|
133 |
<P>
|
134 |
In addition, --file=<i>filename</i> is equivalent to -f<i>filename</i>, and
|
135 |
--help shows the list of options and then exits.
|
136 |
</P>
|
137 |
<br><a name="SEC5" href="#TOC1">DIAGNOSTICS</a><br>
|
138 |
<P>
|
139 |
Exit status is 0 if any matches were found, 1 if no matches were found, and 2
|
140 |
for syntax errors or inacessible files (even if matches were found).
|
141 |
</P>
|
142 |
<br><a name="SEC6" href="#TOC1">AUTHOR</a><br>
|
143 |
<P>
|
144 |
Philip Hazel <ph10@cam.ac.uk>
|
145 |
<br>
|
146 |
University Computing Service
|
147 |
<br>
|
148 |
Cambridge CB2 3QG, England.
|
149 |
</P>
|
150 |
<P>
|
151 |
Last updated: 03 February 2003
|
152 |
<br>
|
153 |
Copyright © 1997-2003 University of Cambridge.
|