1 |
.TH PCREGREP 1
|
2 |
.SH NAME
|
3 |
pcregrep - a grep with Perl-compatible regular expressions.
|
4 |
.SH SYNOPSIS
|
5 |
.B pcregrep [-Vcfhilnrsuvx] [long options] [pattern] [file1 file2 ...]
|
6 |
.
|
7 |
.SH DESCRIPTION
|
8 |
.rs
|
9 |
.sp
|
10 |
\fBpcregrep\fP 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
|
12 |
patterns that are compatible with the regular expressions of Perl 5. See
|
13 |
.\" HREF
|
14 |
\fBpcrepattern\fP
|
15 |
.\"
|
16 |
for a full description of syntax and semantics of the regular expressions that
|
17 |
PCRE supports.
|
18 |
.P
|
19 |
A pattern must be specified on the command line unless the \fB-f\fP option is
|
20 |
used (see below).
|
21 |
.P
|
22 |
If no files are specified, \fBpcregrep\fP reads the standard input. By default,
|
23 |
each line that matches the pattern is copied to the standard output, and if
|
24 |
there is more than one file, the file name is printed before each line of
|
25 |
output. However, there are options that can change how \fBpcregrep\fP behaves.
|
26 |
.P
|
27 |
Lines are limited to BUFSIZ characters. BUFSIZ is defined in \fB<stdio.h>\fP.
|
28 |
The newline character is removed from the end of each line before it is matched
|
29 |
against the pattern.
|
30 |
.
|
31 |
.SH OPTIONS
|
32 |
.rs
|
33 |
.sp
|
34 |
.TP 10
|
35 |
\fB-V\fP
|
36 |
Write the version number of the PCRE library being used to the standard error
|
37 |
stream.
|
38 |
.TP
|
39 |
\fB-c\fP
|
40 |
Do not print individual lines; instead just print a count of the number of
|
41 |
lines that would otherwise have been printed. If several files are given, a
|
42 |
count is printed for each of them.
|
43 |
.TP
|
44 |
\fB-f\fP\fIfilename\fP
|
45 |
Read a number of patterns from the file, one per line, and match all of them
|
46 |
against each line of input. A line is output if any of the patterns match it.
|
47 |
When \fB-f\fP is used, no pattern is taken from the command line; all arguments
|
48 |
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
|
52 |
\fB-h\fP
|
53 |
Suppress printing of filenames when searching multiple files.
|
54 |
.TP
|
55 |
\fB-i\fP
|
56 |
Ignore upper/lower case distinctions during comparisons.
|
57 |
.TP
|
58 |
\fB-l\fP
|
59 |
Instead of printing lines from the files, just print the names of the files
|
60 |
containing lines that would have been printed. Each file name is printed
|
61 |
once, on a separate line.
|
62 |
.TP
|
63 |
\fB-n\fP
|
64 |
Precede each line by its line number in the file.
|
65 |
.TP
|
66 |
\fB-r\fP
|
67 |
If any file is a directory, recursively scan the files it contains. Without
|
68 |
\fB-r\fP a directory is scanned as a normal file.
|
69 |
.TP
|
70 |
\fB-s\fP
|
71 |
Work silently, that is, display nothing except error messages.
|
72 |
The exit status indicates whether any matches were found.
|
73 |
.TP
|
74 |
\fB-u\fP
|
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 must be valid
|
77 |
strings of UTF-8 characters.
|
78 |
.TP
|
79 |
\fB-v\fP
|
80 |
Invert the sense of the match, so that lines which do \fInot\fP match the
|
81 |
pattern are now the ones that are found.
|
82 |
.TP
|
83 |
\fB-x\fP
|
84 |
Force the pattern to be anchored (it must start matching at the beginning of
|
85 |
the line) and in addition, require it to match the entire line. This is
|
86 |
equivalent to having ^ and $ characters at the start and end of each
|
87 |
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 |
.sp
|
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 |
.sp
|
108 |
In addition, --file=\fIfilename\fP is equivalent to -f\fIfilename\fP, and
|
109 |
--help shows the list of options and then exits.
|
110 |
.
|
111 |
.SH DIAGNOSTICS
|
112 |
.rs
|
113 |
.sp
|
114 |
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).
|
116 |
.
|
117 |
.
|
118 |
.SH AUTHOR
|
119 |
.rs
|
120 |
.sp
|
121 |
Philip Hazel <ph10@cam.ac.uk>
|
122 |
.br
|
123 |
University Computing Service
|
124 |
.br
|
125 |
Cambridge CB2 3QG, England.
|
126 |
.P
|
127 |
.in 0
|
128 |
Last updated: 09 September 2004
|
129 |
.br
|
130 |
Copyright (c) 1997-2004 University of Cambridge.
|