--- code/trunk/doc/pcregrep.1 2007/02/24 21:39:58 61 +++ code/trunk/doc/pcregrep.1 2007/02/24 21:40:03 63 @@ -2,14 +2,22 @@ .SH NAME pcregrep - a grep with Perl-compatible regular expressions. .SH SYNOPSIS -.B pcregrep [-Vcfhilnrsvx] pattern [file] ... - +.B pcregrep [-Vcfhilnrsuvx] [long options] [pattern] [file1 file2 ...] .SH DESCRIPTION +.rs +.sp \fBpcregrep\fR searches files for character patterns, in the same way as other grep commands do, but it uses the PCRE regular expression library to support patterns that are compatible with the regular expressions of Perl 5. See -\fBpcre(3)\fR for a full description of syntax and semantics. +.\" HREF +\fBpcrepattern\fR +.\" +for a full description of syntax and semantics of the regular expressions that +PCRE supports. + +A pattern must be specified on the command line unless the \fB-f\fR option is +used (see below). If no files are specified, \fBpcregrep\fR reads the standard input. By default, each line that matches the pattern is copied to the standard output, and if @@ -20,8 +28,9 @@ The newline character is removed from the end of each line before it is matched against the pattern. - .SH OPTIONS +.rs +.sp .TP 10 \fB-V\fR Write the version number of the PCRE library being used to the standard error @@ -32,11 +41,13 @@ lines that would otherwise have been printed. If several files are given, a count is printed for each of them. .TP -\fB-f\fIfilename\fR -Read patterns from the file, one per line, and match all patterns against each -line. There is a maximum of 100 patterns. Trailing white space is removed, and -blank lines are ignored. An empty file contains no patterns and therefore -matches nothing. +\fB-f\fR\fIfilename\fR +Read a number of patterns from the file, one per line, and match all of them +against each line of input. A line is output if any of the patterns match it. +When \fB-f\fR is used, no pattern is taken from the command line; all arguments +are treated as file names. There is a maximum of 100 patterns. Trailing white +space is removed, and blank lines are ignored. An empty file contains no +patterns and therefore matches nothing. .TP \fB-h\fR Suppress printing of filenames when searching multiple files. @@ -60,6 +71,11 @@ Work silently, that is, display nothing except error messages. The exit status indicates whether any matches were found. .TP +\fB-u\fR +Operate in UTF-8 mode. This option is available only if PCRE has been compiled +with UTF-8 support. Both the pattern and each subject line are assumed to be +valid strings of UTF-8 characters. +.TP \fB-v\fR Invert the sense of the match, so that lines which do \fInot\fR match the pattern are now the ones that are found. @@ -70,19 +86,45 @@ equivalent to having ^ and $ characters at the start and end of each alternative branch in the regular expression. +.SH LONG OPTIONS +.rs +.sp +Long forms of all the options are available, as in GNU grep. They are shown in +the following table: + + -c --count + -h --no-filename + -i --ignore-case + -l --files-with-matches + -n --line-number + -r --recursive + -s --no-messages + -u --utf-8 + -V --version + -v --invert-match + -x --line-regex + -x --line-regexp -.SH SEE ALSO -\fBpcre(3)\fR, Perl 5 documentation - +In addition, --file=\fIfilename\fR is equivalent to -f\fIfilename\fR, and +--help shows the list of options and then exits. .SH DIAGNOSTICS +.rs +.sp Exit status is 0 if any matches were found, 1 if no matches were found, and 2 for syntax errors or inacessible files (even if matches were found). .SH AUTHOR +.rs +.sp Philip Hazel +.br +University Computing Service +.br +Cambridge CB2 3QG, England. -Last updated: 15 August 2001 +.in 0 +Last updated: 03 February 2003 .br -Copyright (c) 1997-2001 University of Cambridge. +Copyright (c) 1997-2003 University of Cambridge.