| 1 |
nigel |
49 |
<HTML> |
| 2 |
|
|
<HEAD> |
| 3 |
|
|
<TITLE>pcregrep specification</TITLE> |
| 4 |
|
|
</HEAD> |
| 5 |
|
|
<body bgcolor="#FFFFFF" text="#00005A"> |
| 6 |
|
|
<H1>pcregrep specification</H1> |
| 7 |
|
|
This HTML document has been generated automatically from the original man page. |
| 8 |
|
|
If there is any nonsense in it, please consult the man page in case the |
| 9 |
|
|
conversion went wrong. |
| 10 |
|
|
<UL> |
| 11 |
|
|
<LI><A NAME="TOC1" HREF="#SEC1">NAME</A> |
| 12 |
|
|
<LI><A NAME="TOC2" HREF="#SEC2">SYNOPSIS</A> |
| 13 |
|
|
<LI><A NAME="TOC3" HREF="#SEC3">DESCRIPTION</A> |
| 14 |
|
|
<LI><A NAME="TOC4" HREF="#SEC4">OPTIONS</A> |
| 15 |
|
|
<LI><A NAME="TOC5" HREF="#SEC5">SEE ALSO</A> |
| 16 |
|
|
<LI><A NAME="TOC6" HREF="#SEC6">DIAGNOSTICS</A> |
| 17 |
|
|
<LI><A NAME="TOC7" HREF="#SEC7">AUTHOR</A> |
| 18 |
|
|
</UL> |
| 19 |
|
|
<LI><A NAME="SEC1" HREF="#TOC1">NAME</A> |
| 20 |
|
|
<P> |
| 21 |
|
|
pcregrep - a grep with Perl-compatible regular expressions. |
| 22 |
|
|
</P> |
| 23 |
|
|
<LI><A NAME="SEC2" HREF="#TOC1">SYNOPSIS</A> |
| 24 |
|
|
<P> |
| 25 |
nigel |
53 |
<B>pcregrep [-Vcfhilnrsvx] pattern [file] ...</B> |
| 26 |
nigel |
49 |
</P> |
| 27 |
|
|
<LI><A NAME="SEC3" HREF="#TOC1">DESCRIPTION</A> |
| 28 |
|
|
<P> |
| 29 |
|
|
<B>pcregrep</B> searches files for character patterns, in the same way as other |
| 30 |
|
|
grep commands do, but it uses the PCRE regular expression library to support |
| 31 |
|
|
patterns that are compatible with the regular expressions of Perl 5. See |
| 32 |
|
|
<B>pcre(3)</B> for a full description of syntax and semantics. |
| 33 |
|
|
</P> |
| 34 |
|
|
<P> |
| 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. |
| 39 |
|
|
</P> |
| 40 |
|
|
<P> |
| 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 |
| 43 |
|
|
against the pattern. |
| 44 |
|
|
</P> |
| 45 |
|
|
<LI><A NAME="SEC4" HREF="#TOC1">OPTIONS</A> |
| 46 |
|
|
<P> |
| 47 |
|
|
<B>-V</B> |
| 48 |
|
|
Write the version number of the PCRE library being used to the standard error |
| 49 |
|
|
stream. |
| 50 |
|
|
</P> |
| 51 |
|
|
<P> |
| 52 |
|
|
<B>-c</B> |
| 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. |
| 56 |
|
|
</P> |
| 57 |
|
|
<P> |
| 58 |
nigel |
61 |
\fB-f<I>filename</I> |
| 59 |
nigel |
53 |
Read patterns from the file, one per line, and match all patterns against each |
| 60 |
|
|
line. There is a maximum of 100 patterns. Trailing white space is removed, and |
| 61 |
|
|
blank lines are ignored. An empty file contains no patterns and therefore |
| 62 |
|
|
matches nothing. |
| 63 |
|
|
</P> |
| 64 |
|
|
<P> |
| 65 |
nigel |
49 |
<B>-h</B> |
| 66 |
|
|
Suppress printing of filenames when searching multiple files. |
| 67 |
|
|
</P> |
| 68 |
|
|
<P> |
| 69 |
|
|
<B>-i</B> |
| 70 |
|
|
Ignore upper/lower case distinctions during comparisons. |
| 71 |
|
|
</P> |
| 72 |
|
|
<P> |
| 73 |
|
|
<B>-l</B> |
| 74 |
|
|
Instead of printing lines from the files, just print the names of the files |
| 75 |
|
|
containing lines that would have been printed. Each file name is printed |
| 76 |
|
|
once, on a separate line. |
| 77 |
|
|
</P> |
| 78 |
|
|
<P> |
| 79 |
|
|
<B>-n</B> |
| 80 |
|
|
Precede each line by its line number in the file. |
| 81 |
|
|
</P> |
| 82 |
|
|
<P> |
| 83 |
nigel |
53 |
<B>-r</B> |
| 84 |
|
|
If any file is a directory, recursively scan the files it contains. Without |
| 85 |
|
|
<B>-r</B> a directory is scanned as a normal file. |
| 86 |
|
|
</P> |
| 87 |
|
|
<P> |
| 88 |
nigel |
49 |
<B>-s</B> |
| 89 |
|
|
Work silently, that is, display nothing except error messages. |
| 90 |
|
|
The exit status indicates whether any matches were found. |
| 91 |
|
|
</P> |
| 92 |
|
|
<P> |
| 93 |
|
|
<B>-v</B> |
| 94 |
|
|
Invert the sense of the match, so that lines which do <I>not</I> match the |
| 95 |
|
|
pattern are now the ones that are found. |
| 96 |
|
|
</P> |
| 97 |
|
|
<P> |
| 98 |
|
|
<B>-x</B> |
| 99 |
|
|
Force the pattern to be anchored (it must start matching at the beginning of |
| 100 |
|
|
the line) and in addition, require it to match the entire line. This is |
| 101 |
|
|
equivalent to having ^ and $ characters at the start and end of each |
| 102 |
|
|
alternative branch in the regular expression. |
| 103 |
|
|
</P> |
| 104 |
|
|
<LI><A NAME="SEC5" HREF="#TOC1">SEE ALSO</A> |
| 105 |
|
|
<P> |
| 106 |
|
|
<B>pcre(3)</B>, Perl 5 documentation |
| 107 |
|
|
</P> |
| 108 |
|
|
<LI><A NAME="SEC6" HREF="#TOC1">DIAGNOSTICS</A> |
| 109 |
|
|
<P> |
| 110 |
|
|
Exit status is 0 if any matches were found, 1 if no matches were found, and 2 |
| 111 |
|
|
for syntax errors or inacessible files (even if matches were found). |
| 112 |
|
|
</P> |
| 113 |
|
|
<LI><A NAME="SEC7" HREF="#TOC1">AUTHOR</A> |
| 114 |
|
|
<P> |
| 115 |
|
|
Philip Hazel <ph10@cam.ac.uk> |
| 116 |
nigel |
53 |
</P> |
| 117 |
|
|
<P> |
| 118 |
|
|
Last updated: 15 August 2001 |
| 119 |
nigel |
49 |
<BR> |
| 120 |
nigel |
53 |
Copyright (c) 1997-2001 University of Cambridge. |