| 1 |
nigel |
49 |
.TH PCREGREP 1 |
| 2 |
|
|
.SH NAME |
| 3 |
|
|
pcregrep - a grep with Perl-compatible regular expressions. |
| 4 |
|
|
.SH SYNOPSIS |
| 5 |
nigel |
63 |
.B pcregrep [-Vcfhilnrsuvx] [long options] [pattern] [file1 file2 ...] |
| 6 |
nigel |
75 |
. |
| 7 |
nigel |
49 |
.SH DESCRIPTION |
| 8 |
nigel |
63 |
.rs |
| 9 |
|
|
.sp |
| 10 |
nigel |
75 |
\fBpcregrep\fP searches files for character patterns, in the same way as other |
| 11 |
nigel |
49 |
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 |
nigel |
63 |
.\" HREF |
| 14 |
nigel |
75 |
\fBpcrepattern\fP |
| 15 |
nigel |
63 |
.\" |
| 16 |
|
|
for a full description of syntax and semantics of the regular expressions that |
| 17 |
|
|
PCRE supports. |
| 18 |
nigel |
75 |
.P |
| 19 |
|
|
A pattern must be specified on the command line unless the \fB-f\fP option is |
| 20 |
nigel |
63 |
used (see below). |
| 21 |
nigel |
75 |
.P |
| 22 |
|
|
If no files are specified, \fBpcregrep\fP reads the standard input. By default, |
| 23 |
nigel |
49 |
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 |
nigel |
75 |
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 |
nigel |
49 |
The newline character is removed from the end of each line before it is matched |
| 29 |
|
|
against the pattern. |
| 30 |
nigel |
75 |
. |
| 31 |
nigel |
49 |
.SH OPTIONS |
| 32 |
nigel |
63 |
.rs |
| 33 |
|
|
.sp |
| 34 |
nigel |
49 |
.TP 10 |
| 35 |
nigel |
75 |
\fB-V\fP |
| 36 |
nigel |
49 |
Write the version number of the PCRE library being used to the standard error |
| 37 |
|
|
stream. |
| 38 |
|
|
.TP |
| 39 |
nigel |
75 |
\fB-c\fP |
| 40 |
nigel |
49 |
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 |
nigel |
75 |
\fB-f\fP\fIfilename\fP |
| 45 |
nigel |
63 |
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 |
nigel |
75 |
When \fB-f\fP is used, no pattern is taken from the command line; all arguments |
| 48 |
nigel |
63 |
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 |
nigel |
53 |
.TP |
| 52 |
nigel |
75 |
\fB-h\fP |
| 53 |
nigel |
49 |
Suppress printing of filenames when searching multiple files. |
| 54 |
|
|
.TP |
| 55 |
nigel |
75 |
\fB-i\fP |
| 56 |
nigel |
49 |
Ignore upper/lower case distinctions during comparisons. |
| 57 |
|
|
.TP |
| 58 |
nigel |
75 |
\fB-l\fP |
| 59 |
nigel |
49 |
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 |
nigel |
75 |
\fB-n\fP |
| 64 |
nigel |
49 |
Precede each line by its line number in the file. |
| 65 |
|
|
.TP |
| 66 |
nigel |
75 |
\fB-r\fP |
| 67 |
nigel |
53 |
If any file is a directory, recursively scan the files it contains. Without |
| 68 |
nigel |
75 |
\fB-r\fP a directory is scanned as a normal file. |
| 69 |
nigel |
53 |
.TP |
| 70 |
nigel |
75 |
\fB-s\fP |
| 71 |
nigel |
49 |
Work silently, that is, display nothing except error messages. |
| 72 |
|
|
The exit status indicates whether any matches were found. |
| 73 |
|
|
.TP |
| 74 |
nigel |
75 |
\fB-u\fP |
| 75 |
nigel |
63 |
Operate in UTF-8 mode. This option is available only if PCRE has been compiled |
| 76 |
nigel |
75 |
with UTF-8 support. Both the pattern and each subject line must be valid |
| 77 |
|
|
strings of UTF-8 characters. |
| 78 |
nigel |
63 |
.TP |
| 79 |
nigel |
75 |
\fB-v\fP |
| 80 |
|
|
Invert the sense of the match, so that lines which do \fInot\fP match the |
| 81 |
nigel |
49 |
pattern are now the ones that are found. |
| 82 |
|
|
.TP |
| 83 |
nigel |
75 |
\fB-x\fP |
| 84 |
nigel |
49 |
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 |
nigel |
75 |
. |
| 89 |
|
|
.SH "LONG OPTIONS" |
| 90 |
nigel |
63 |
.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 |
nigel |
75 |
.sp |
| 95 |
nigel |
63 |
-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 |
nigel |
75 |
.sp |
| 108 |
|
|
In addition, --file=\fIfilename\fP is equivalent to -f\fIfilename\fP, and |
| 109 |
nigel |
63 |
--help shows the list of options and then exits. |
| 110 |
nigel |
75 |
. |
| 111 |
nigel |
49 |
.SH DIAGNOSTICS |
| 112 |
nigel |
63 |
.rs |
| 113 |
|
|
.sp |
| 114 |
nigel |
49 |
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 |
nigel |
75 |
. |
| 117 |
|
|
. |
| 118 |
nigel |
49 |
.SH AUTHOR |
| 119 |
nigel |
63 |
.rs |
| 120 |
|
|
.sp |
| 121 |
nigel |
49 |
Philip Hazel <ph10@cam.ac.uk> |
| 122 |
nigel |
63 |
.br |
| 123 |
|
|
University Computing Service |
| 124 |
|
|
.br |
| 125 |
|
|
Cambridge CB2 3QG, England. |
| 126 |
nigel |
75 |
.P |
| 127 |
nigel |
63 |
.in 0 |
| 128 |
nigel |
75 |
Last updated: 09 September 2004 |
| 129 |
nigel |
49 |
.br |
| 130 |
nigel |
75 |
Copyright (c) 1997-2004 University of Cambridge. |