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