/[pcre]/code/trunk/doc/pcregrep.1
ViewVC logotype

Contents of /code/trunk/doc/pcregrep.1

Parent Directory Parent Directory | Revision Log Revision Log


Revision 63 - (hide annotations) (download)
Sat Feb 24 21:40:03 2007 UTC (7 years, 1 month ago) by nigel
File size: 4058 byte(s)
Load pcre-4.0 into code/trunk.

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 49
7     .SH DESCRIPTION
8 nigel 63 .rs
9     .sp
10 nigel 49 \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
12     patterns that are compatible with the regular expressions of Perl 5. See
13 nigel 63 .\" HREF
14     \fBpcrepattern\fR
15     .\"
16     for a full description of syntax and semantics of the regular expressions that
17     PCRE supports.
18 nigel 49
19 nigel 63 A pattern must be specified on the command line unless the \fB-f\fR option is
20     used (see below).
21    
22 nigel 49 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
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\fR behaves.
26    
27     Lines are limited to BUFSIZ characters. BUFSIZ is defined in \fB<stdio.h>\fR.
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 nigel 63 .rs
33     .sp
34 nigel 49 .TP 10
35     \fB-V\fR
36     Write the version number of the PCRE library being used to the standard error
37     stream.
38     .TP
39     \fB-c\fR
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 nigel 63 \fB-f\fR\fIfilename\fR
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\fR 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 nigel 53 .TP
52 nigel 49 \fB-h\fR
53     Suppress printing of filenames when searching multiple files.
54     .TP
55     \fB-i\fR
56     Ignore upper/lower case distinctions during comparisons.
57     .TP
58     \fB-l\fR
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\fR
64     Precede each line by its line number in the file.
65     .TP
66 nigel 53 \fB-r\fR
67     If any file is a directory, recursively scan the files it contains. Without
68     \fB-r\fR a directory is scanned as a normal file.
69     .TP
70 nigel 49 \fB-s\fR
71     Work silently, that is, display nothing except error messages.
72     The exit status indicates whether any matches were found.
73     .TP
74 nigel 63 \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 nigel 49 \fB-v\fR
80     Invert the sense of the match, so that lines which do \fInot\fR match the
81     pattern are now the ones that are found.
82     .TP
83     \fB-x\fR
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 nigel 63 .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 nigel 49
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 49
108 nigel 63 In addition, --file=\fIfilename\fR is equivalent to -f\fIfilename\fR, and
109     --help shows the list of options and then exits.
110 nigel 49
111     .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    
117    
118     .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 53
127 nigel 63 .in 0
128     Last updated: 03 February 2003
129 nigel 49 .br
130 nigel 63 Copyright (c) 1997-2003 University of Cambridge.

webmaster@exim.org
ViewVC Help
Powered by ViewVC 1.1.12