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 [-Vcfhilnrsvx] pattern [file] ... |
.B pcregrep [-Vcfhilnrsuvx] [long options] [pattern] [file1 file2 ...] |
|
|
|
6 |
|
|
7 |
.SH DESCRIPTION |
.SH DESCRIPTION |
8 |
|
.rs |
9 |
|
.sp |
10 |
\fBpcregrep\fR searches files for character patterns, in the same way as other |
\fBpcregrep\fR searches files for character patterns, in the same way as other |
11 |
grep commands do, but it uses the PCRE regular expression library to support |
grep commands do, but it uses the PCRE regular expression library to support |
12 |
patterns that are compatible with the regular expressions of Perl 5. See |
patterns that are compatible with the regular expressions of Perl 5. See |
13 |
\fBpcre(3)\fR for a full description of syntax and semantics. |
.\" HREF |
14 |
|
\fBpcrepattern\fR |
15 |
|
.\" |
16 |
|
for a full description of syntax and semantics of the regular expressions that |
17 |
|
PCRE supports. |
18 |
|
|
19 |
|
A pattern must be specified on the command line unless the \fB-f\fR option is |
20 |
|
used (see below). |
21 |
|
|
22 |
If no files are specified, \fBpcregrep\fR reads the standard input. By default, |
If no files are specified, \fBpcregrep\fR reads the standard input. By default, |
23 |
each line that matches the pattern is copied to the standard output, and if |
each line that matches the pattern is copied to the standard output, and if |
28 |
The newline character is removed from the end of each line before it is matched |
The newline character is removed from the end of each line before it is matched |
29 |
against the pattern. |
against the pattern. |
30 |
|
|
|
|
|
31 |
.SH OPTIONS |
.SH OPTIONS |
32 |
|
.rs |
33 |
|
.sp |
34 |
.TP 10 |
.TP 10 |
35 |
\fB-V\fR |
\fB-V\fR |
36 |
Write the version number of the PCRE library being used to the standard error |
Write the version number of the PCRE library being used to the standard error |
41 |
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 |
42 |
count is printed for each of them. |
count is printed for each of them. |
43 |
.TP |
.TP |
44 |
\fB-f\fIfilename\fR |
\fB-f\fR\fIfilename\fR |
45 |
Read patterns from the file, one per line, and match all patterns against each |
Read a number of patterns from the file, one per line, and match all of them |
46 |
line. There is a maximum of 100 patterns. Trailing white space is removed, and |
against each line of input. A line is output if any of the patterns match it. |
47 |
blank lines are ignored. An empty file contains no patterns and therefore |
When \fB-f\fR is used, no pattern is taken from the command line; all arguments |
48 |
matches nothing. |
are treated as file names. There is a maximum of 100 patterns. Trailing white |
49 |
|
space is removed, and blank lines are ignored. An empty file contains no |
50 |
|
patterns and therefore matches nothing. |
51 |
.TP |
.TP |
52 |
\fB-h\fR |
\fB-h\fR |
53 |
Suppress printing of filenames when searching multiple files. |
Suppress printing of filenames when searching multiple files. |
71 |
Work silently, that is, display nothing except error messages. |
Work silently, that is, display nothing except error messages. |
72 |
The exit status indicates whether any matches were found. |
The exit status indicates whether any matches were found. |
73 |
.TP |
.TP |
74 |
|
\fB-u\fR |
75 |
|
Operate in UTF-8 mode. This option is available only if PCRE has been compiled |
76 |
|
with UTF-8 support. Both the pattern and each subject line are assumed to be |
77 |
|
valid strings of UTF-8 characters. |
78 |
|
.TP |
79 |
\fB-v\fR |
\fB-v\fR |
80 |
Invert the sense of the match, so that lines which do \fInot\fR match the |
Invert the sense of the match, so that lines which do \fInot\fR match the |
81 |
pattern are now the ones that are found. |
pattern are now the ones that are found. |
86 |
equivalent to having ^ and $ characters at the start and end of each |
equivalent to having ^ and $ characters at the start and end of each |
87 |
alternative branch in the regular expression. |
alternative branch in the regular expression. |
88 |
|
|
89 |
|
.SH LONG OPTIONS |
90 |
|
.rs |
91 |
|
.sp |
92 |
|
Long forms of all the options are available, as in GNU grep. They are shown in |
93 |
|
the following table: |
94 |
|
|
95 |
|
-c --count |
96 |
|
-h --no-filename |
97 |
|
-i --ignore-case |
98 |
|
-l --files-with-matches |
99 |
|
-n --line-number |
100 |
|
-r --recursive |
101 |
|
-s --no-messages |
102 |
|
-u --utf-8 |
103 |
|
-V --version |
104 |
|
-v --invert-match |
105 |
|
-x --line-regex |
106 |
|
-x --line-regexp |
107 |
|
|
108 |
.SH SEE ALSO |
In addition, --file=\fIfilename\fR is equivalent to -f\fIfilename\fR, and |
109 |
\fBpcre(3)\fR, Perl 5 documentation |
--help shows the list of options and then exits. |
|
|
|
110 |
|
|
111 |
.SH DIAGNOSTICS |
.SH DIAGNOSTICS |
112 |
|
.rs |
113 |
|
.sp |
114 |
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 |
115 |
for syntax errors or inacessible files (even if matches were found). |
for syntax errors or inacessible files (even if matches were found). |
116 |
|
|
117 |
|
|
118 |
.SH AUTHOR |
.SH AUTHOR |
119 |
|
.rs |
120 |
|
.sp |
121 |
Philip Hazel <ph10@cam.ac.uk> |
Philip Hazel <ph10@cam.ac.uk> |
122 |
|
.br |
123 |
|
University Computing Service |
124 |
|
.br |
125 |
|
Cambridge CB2 3QG, England. |
126 |
|
|
127 |
Last updated: 15 August 2001 |
.in 0 |
128 |
|
Last updated: 03 February 2003 |
129 |
.br |
.br |
130 |
Copyright (c) 1997-2001 University of Cambridge. |
Copyright (c) 1997-2003 University of Cambridge. |