3
<title>pcregrep specification</title>
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>
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>
17
<br><a name="SEC1" href="#TOC1">SYNOPSIS</a><br>
19
<b>pcregrep [-Vcfhilnrsuvx] [long options] [pattern] [file1 file2 ...]</b>
21
<br><a name="SEC2" href="#TOC1">DESCRIPTION</a><br>
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
31
A pattern must be specified on the command line unless the <b>-f</b> option is
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.
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
45
<br><a name="SEC3" href="#TOC1">OPTIONS</a><br>
48
Write the version number of the PCRE library being used to the standard error
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.
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.
68
Suppress printing of filenames when searching multiple files.
72
Ignore upper/lower case distinctions during comparisons.
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.
82
Precede each line by its line number in the file.
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.
91
Work silently, that is, display nothing except error messages.
92
The exit status indicates whether any matches were found.
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.
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.
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.
112
<br><a name="SEC4" href="#TOC1">LONG OPTIONS</a><br>
114
Long forms of all the options are available, as in GNU grep. They are shown in
122
-l --files-with-matches
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.
137
<br><a name="SEC5" href="#TOC1">DIAGNOSTICS</a><br>
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).
142
<br><a name="SEC6" href="#TOC1">AUTHOR</a><br>
144
Philip Hazel <ph10@cam.ac.uk>
146
University Computing Service
148
Cambridge CB2 3QG, England.
151
Last updated: 03 February 2003
153
Copyright © 1997-2003 University of Cambridge.