| 1 |
NAME |
PCREGREP(1) PCREGREP(1) |
| 2 |
pcregrep - a grep with Perl-compatible regular expressions. |
|
| 3 |
|
|
| 4 |
|
|
| 5 |
|
NAME |
| 6 |
|
pcregrep - a grep with Perl-compatible regular expressions. |
| 7 |
|
|
| 8 |
SYNOPSIS |
SYNOPSIS |
| 9 |
pcregrep [-Vcfhilnrsuvx] [long options] [pattern] [file1 |
pcregrep [-Vcfhilnrsuvx] [long options] [pattern] [file1 file2 ...] |
| 10 |
|
|
| 11 |
|
|
| 12 |
DESCRIPTION |
DESCRIPTION |
| 13 |
|
|
| 14 |
pcregrep searches files for character patterns, in the same |
pcregrep searches files for character patterns, in the same way as |
| 15 |
way as other grep commands do, but it uses the PCRE regular |
other grep commands do, but it uses the PCRE regular expression library |
| 16 |
expression library to support patterns that are compatible |
to support patterns that are compatible with the regular expressions of |
| 17 |
with the regular expressions of Perl 5. See pcrepattern for |
Perl 5. See pcrepattern for a full description of syntax and semantics |
| 18 |
a full description of syntax and semantics of the regular |
of the regular expressions that PCRE supports. |
| 19 |
expressions that PCRE supports. |
|
| 20 |
|
A pattern must be specified on the command line unless the -f option is |
| 21 |
A pattern must be specified on the command line unless the |
used (see below). |
| 22 |
-f option is used (see below). |
|
| 23 |
|
If no files are specified, pcregrep reads the standard input. By |
| 24 |
If no files are specified, pcregrep reads the standard |
default, each line that matches the pattern is copied to the standard |
| 25 |
input. By default, each line that matches the pattern is |
output, and if there is more than one file, the file name is printed |
| 26 |
copied to the standard output, and if there is more than one |
before each line of output. However, there are options that can change |
| 27 |
file, the file name is printed before each line of output. |
how pcregrep behaves. |
| 28 |
However, there are options that can change how pcregrep |
|
| 29 |
behaves. |
Lines are limited to BUFSIZ characters. BUFSIZ is defined in <stdio.h>. |
| 30 |
|
The newline character is removed from the end of each line before it is |
| 31 |
Lines are limited to BUFSIZ characters. BUFSIZ is defined in |
matched against the pattern. |
|
<stdio.h>. The newline character is removed from the end of |
|
|
each line before it is matched against the pattern. |
|
| 32 |
|
|
| 33 |
|
|
| 34 |
OPTIONS |
OPTIONS |
| 35 |
|
|
| 36 |
|
|
| 37 |
-V Write the version number of the PCRE library being |
-V Write the version number of the PCRE library being used to |
| 38 |
used to the standard error stream. |
the standard error stream. |
| 39 |
|
|
| 40 |
-c Do not print individual lines; instead just print |
-c Do not print individual lines; instead just print a count of |
| 41 |
a count of the number of lines that would other- |
the number of lines that would otherwise have been printed. |
| 42 |
wise have been printed. If several files are |
If several files are given, a count is printed for each of |
| 43 |
given, a count is printed for each of them. |
them. |
| 44 |
|
|
| 45 |
-ffilename |
-ffilename |
| 46 |
Read a number of patterns from the file, one per |
Read a number of patterns from the file, one per line, and |
| 47 |
line, and match all of them against each line of |
match all of them against each line of input. A line is out- |
| 48 |
input. A line is output if any of the patterns |
put if any of the patterns match it. When -f is used, no |
| 49 |
match it. When -f is used, no pattern is taken |
pattern is taken from the command line; all arguments are |
| 50 |
from the command line; all arguments are treated |
treated as file names. There is a maximum of 100 patterns. |
| 51 |
as file names. There is a maximum of 100 patterns. |
Trailing white space is removed, and blank lines are ignored. |
| 52 |
Trailing white space is removed, and blank lines |
An empty file contains no patterns and therefore matches |
| 53 |
are ignored. An empty file contains no patterns |
nothing. |
| 54 |
and therefore matches nothing. |
|
| 55 |
|
-h Suppress printing of filenames when searching multiple files. |
| 56 |
-h Suppress printing of filenames when searching mul- |
|
| 57 |
tiple files. |
-i Ignore upper/lower case distinctions during comparisons. |
| 58 |
|
|
| 59 |
-i Ignore upper/lower case distinctions during com- |
-l Instead of printing lines from the files, just print the |
| 60 |
parisons. |
names of the files containing lines that would have been |
| 61 |
|
printed. Each file name is printed once, on a separate line. |
| 62 |
-l Instead of printing lines from the files, just |
|
| 63 |
print the names of the files containing lines that |
-n Precede each line by its line number in the file. |
| 64 |
would have been printed. Each file name is printed |
|
| 65 |
once, on a separate line. |
-r If any file is a directory, recursively scan the files it |
| 66 |
|
contains. Without -r a directory is scanned as a normal file. |
| 67 |
-n Precede each line by its line number in the file. |
|
| 68 |
|
-s Work silently, that is, display nothing except error mes- |
| 69 |
-r If any file is a directory, recursively scan the |
sages. The exit status indicates whether any matches were |
| 70 |
files it contains. Without -r a directory is |
found. |
| 71 |
scanned as a normal file. |
|
| 72 |
|
-u Operate in UTF-8 mode. This option is available only if PCRE |
| 73 |
-s Work silently, that is, display nothing except |
has been compiled with UTF-8 support. Both the pattern and |
| 74 |
error messages. The exit status indicates whether |
each subject line are assumed to be valid strings of UTF-8 |
| 75 |
any matches were found. |
characters. |
| 76 |
|
|
| 77 |
-u Operate in UTF-8 mode. This option is available |
-v Invert the sense of the match, so that lines which do not |
| 78 |
only if PCRE has been compiled with UTF-8 support. |
match the pattern are now the ones that are found. |
| 79 |
Both the pattern and each subject line are assumed |
|
| 80 |
to be valid strings of UTF-8 characters. |
-x Force the pattern to be anchored (it must start matching at |
| 81 |
|
the beginning of the line) and in addition, require it to |
| 82 |
-v Invert the sense of the match, so that lines which |
match the entire line. This is equivalent to having ^ and $ |
| 83 |
do not match the pattern are now the ones that are |
characters at the start and end of each alternative branch in |
| 84 |
found. |
the regular expression. |
|
|
|
|
-x 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. |
|
| 85 |
|
|
| 86 |
|
|
| 87 |
LONG OPTIONS |
LONG OPTIONS |
| 88 |
|
|
| 89 |
Long forms of all the options are available, as in GNU grep. |
Long forms of all the options are available, as in GNU grep. They are |
| 90 |
They are shown in the following table: |
shown in the following table: |
| 91 |
|
|
| 92 |
-c --count |
-c --count |
| 93 |
-h --no-filename |
-h --no-filename |
| 94 |
-i --ignore-case |
-i --ignore-case |
| 95 |
-l --files-with-matches |
-l --files-with-matches |
| 96 |
-n --line-number |
-n --line-number |
| 97 |
-r --recursive |
-r --recursive |
| 98 |
-s --no-messages |
-s --no-messages |
| 99 |
-u --utf-8 |
-u --utf-8 |
| 100 |
-V --version |
-V --version |
| 101 |
-v --invert-match |
-v --invert-match |
| 102 |
-x --line-regex |
-x --line-regex |
| 103 |
-x --line-regexp |
-x --line-regexp |
| 104 |
|
|
| 105 |
In addition, --file=filename is equivalent to -ffilename, |
In addition, --file=filename is equivalent to -ffilename, and --help |
| 106 |
and --help shows the list of options and then exits. |
shows the list of options and then exits. |
| 107 |
|
|
| 108 |
|
|
| 109 |
DIAGNOSTICS |
DIAGNOSTICS |
| 110 |
|
|
| 111 |
Exit status is 0 if any matches were found, 1 if no matches |
Exit status is 0 if any matches were found, 1 if no matches were found, |
| 112 |
were found, and 2 for syntax errors or inacessible files |
and 2 for syntax errors or inacessible files (even if matches were |
| 113 |
(even if matches were found). |
found). |
| 114 |
|
|
| 115 |
|
|
| 116 |
|
|
| 117 |
AUTHOR |
AUTHOR |
| 118 |
|
|
| 119 |
Philip Hazel <ph10@cam.ac.uk> |
Philip Hazel <ph10@cam.ac.uk> |
| 120 |
University Computing Service |
University Computing Service |
| 121 |
Cambridge CB2 3QG, England. |
Cambridge CB2 3QG, England. |
| 122 |
|
|
| 123 |
Last updated: 03 February 2003 |
Last updated: 03 February 2003 |
| 124 |
Copyright (c) 1997-2003 University of Cambridge. |
Copyright (c) 1997-2003 University of Cambridge. |