diff options
Diffstat (limited to 'gnu/usr.bin/grep/grep.1')
-rw-r--r-- | gnu/usr.bin/grep/grep.1 | 261 |
1 files changed, 170 insertions, 91 deletions
diff --git a/gnu/usr.bin/grep/grep.1 b/gnu/usr.bin/grep/grep.1 index 6f5c48a..5230af8 100644 --- a/gnu/usr.bin/grep/grep.1 +++ b/gnu/usr.bin/grep/grep.1 @@ -1,15 +1,26 @@ -.TH GREP 1 "1992 September 10" "GNU Project" +.\" grep man page +.\" $FreeBSD$ +.de Id +.ds Dt \\$4 +.. +.Id $Id: grep.1,v 1.1 1998/11/22 06:45:20 alainm Exp $ +.TH GREP 1 \*(Dt "GNU Project" .SH NAME grep, egrep, fgrep, zgrep \- print lines matching a pattern .SH SYNOPSIS .B grep -[\-[AB] num] -[\-HRPS] -[\-CEFGLVabchilnqsvwx] -[\-e expr] -[\-f file] -files... - +[-[AB] NUM] [-CEFGVZabchiLlnqrsvwxyUu] [-e PATTERN | -f FILE] +[-d ACTION] [--directories=ACTION] +[--extended-regexp] [--fixed-strings] [--basic-regexp] +[--regexp=PATTERN] [--file=FILE] [--ignore-case] [--word-regexp] +[--line-regexp] [--line-regexp] [--no-messages] [--revert-match] +[--version] [--help] [--byte-offset] [--line-number] +[--with-filename] [--no-filename] [--quiet] [--silent] [--text] +[--files-without-match] [--files-with-matcces] [--count] +[--before-context=NUM] [--after-context=NUM] [--context] +[--binary] [--unix-byte-offsets] [--recursive] +[--decompress] +.I files... .SH DESCRIPTION .PP .B Grep @@ -30,17 +41,17 @@ There are three major variants of controlled by the following options. .PD 0 .TP -.B \-G +.B \-G, --basic-regexp Interpret .I pattern as a basic regular expression (see below). This is the default. .TP -.B \-E +.B \-E, --extended-regexp Interpret .I pattern as an extended regular expression (see below). .TP -.B \-F +.B \-F, --fixed-strings Interpret .I pattern as a list of fixed strings, separated by newlines, @@ -59,11 +70,9 @@ and is compatible with the historical Unix .B Fgrep is the same as .BR "grep\ \-F" . -When called as -.BR zgrep , -the -.BR \-Z -option is assumed. +.B Zgrep +is the same as +.BR "grep\ \-Z" . .PD .LP All variants of @@ -71,90 +80,157 @@ All variants of understand the following options: .PD 0 .TP -.BI \- num -Matches will be printed with -.I num -lines of leading and trailing context. However, -.B grep -will never print any given line more than once. -.TP -.BI \-A " num" +.BI \-A " NUM" ", --after-context=" NUM Print -.I num +.I NUM lines of trailing context after matching lines. .TP -.BI \-B " num" +.BI \-B " NUM" ", --before-context=" NUM Print -.I num +.I NUM lines of leading context before matching lines. .TP -.B \-C -Equivalent to -.BR \-2 . +.BI \-C ,\ --context"[=NUM]" +Print +.I NUM +lines (default 2) of output context. +.TP +.BI \- NUM \ +Same as --context=NUM lines of leading and trailing context. However, +.B grep +will never print any given line more than once. .TP -.B \-V +.B \-V, --version Print the version number of .B grep to standard error. This version number should be included in all bug reports (see below). .TP -.B \-a -Don't search in binary files. -.TP -.B \-b +.B \-b, --byte-offset Print the byte offset within the input file before each line of output. .TP -.B \-c +.B \-c, --count Suppress normal output; instead print a count of matching lines for each input file. With the -.B \-v +.B \-v, --revert-match option (see below), count non-matching lines. .TP -.BI \-e " pattern" +.BI \-d " ACTION" ", --directories=" ACTION +If an input file is a directory, use +.I ACTION +to process it. By default, +.I ACTION +is +.BR read , +which means that directories are read just as if they were ordinary files. +If +.I ACTION +is +.BR skip , +directories are silently skipped. +If +.I ACTION +is +.BR recurse , +.B +grep reads all files under each directory, recursively; +this is equivalent to the +.B \-r +option. +.TP +.BI \-e " PATTERN" ", --regexp=" PATTERN Use -.I pattern +.I PATTERN as the pattern; useful to protect patterns beginning with .BR \- . .TP -.BI \-f " file" -Obtain the pattern from -.IR file . +.BI \-f " FILE" ", --file=" FILE +Obtain patterns from +.IR FILE , +one per line. +The empty file contains zero patterns, and therfore matches nothing. .TP -.B \-h +.B \-h, --no-filename Suppress the prefixing of filenames on output when multiple files are searched. .TP -.B \-i +.B \-i, --ignore-case Ignore case distinctions in both the .I pattern and the input files. .TP -.B \-L +.B \-L, --files-without-match Suppress normal output; instead print the name of each input file from which no output would -normally have been printed. +normally have been printed. The scanning will stop +on the first match. .TP -.B \-l +.B \-l, --files-with-matches Suppress normal output; instead print the name of each input file from which output -would normally have been printed. +would normally have been printed. The scanning will +stop on the first match. .TP -.B \-n +.B \-n, --line-number Prefix each line of output with the line number within its input file. .TP -.B \-q -Quiet; suppress normal output. -.TP +.B \-q, --quiet, --silent +Quiet; suppress normal output. The scanning will stop +on the first match. +Also see the .B \-s +or +.B --no-messages +option below. +.TP +.B \-r, --recursive +Read all files under each directory, recursively; +this is equivalent to the +.B "\-d recurse" +option. +.TP +.B \-s, --no-messages Suppress error messages about nonexistent or unreadable files. +Portability note: unlike GNU +.BR grep , +BSD +.B grep +does not comply with POSIX.2, because BSD +.B grep +lacks a +.B \-q +option and its +.B \-s +option behaves like GNU +.BR grep 's +.B \-q +option. +Shell scripts intended to be portable to BSD +.B grep +should avoid both +.B \-q +and +.B \-s +and should redirect output to /dev/null instead. .TP -.B \-v +.B \-a, --text +Do not suppress output lines that contain binary data. +Normally, if the first few bytes of a file indicate that +the file contains binary data, +.B grep +outputs only a message saying that the file matches the pattern. +This option causes +.B grep +to act as if the file is a text file, +even if it would otherwise be treated as binary. +.TP +.B \-v, --revert-match Invert the sense of matching, to select non-matching lines. .TP -.B \-w +.B \-w, --word-regexp Select only those lines containing matches that form whole words. The test is that the matching substring must either be at the beginning of the line, or preceded by a non-word constituent @@ -162,44 +238,48 @@ character. Similarly, it must be either at the end of the line or followed by a non-word constituent character. Word-constituent characters are letters, digits, and the underscore. .TP -.B \-x +.B \-x, --line-regexp Select only those matches that exactly match the whole line. - -.PP -Following options are only available if compiled with FTS library: -.PD 0 .TP -.BI \-H -If the -.I \-R -option is specified, symbolic links on the command line -are followed. (Symbolic links encountered in the tree traversal -are not followed.) -.TP -.BI \-L -If the -.I \-R -option is specified, all symbolic links are followed. -.TP -.BI \-P -If the -.I \-R -option is specified, no symbolic links are followed. -.TP -.BI \-R -Search in the file hierarchies -rooted in the files instead of just the files themselves. - +.B \-y +Obsolete synonym for +.BR \-i . +.TP +.B \-U, --binary +Treat the file(s) as binary. By default, under MS-DOS and MS-Windows, +.BR grep +guesses the file type by looking at the contents of the first 32KB +read from the file. If +.BR grep +decides the file is a text file, it strips the CR characters from the +original file contents (to make regular expressions with +.B ^ +and +.B $ +work correctly). Specifying +.B \-U +overrules this guesswork, causing all files to be read and passed to the +matching mechanism verbatim; if the file is a text file with CR/LF +pairs at the end of each line, this will cause some regular +expressions to fail. This option is only supported on MS-DOS and +MS-Windows. +.TP +.B \-u, --unix-byte-offsets +Report Unix-style byte offsets. This switch causes +.B grep +to report byte offsets as if the file were Unix-style text file, i.e. with +CR characters stripped off. This will produce results identical to running +.B grep +on a Unix machine. This option has no effect unless +.B \-b +option is also used; it is only supported on MS-DOS and MS-Windows. +.PD .LP -Following option is only available if compiled with zlib library: +Following option is only available if compiled with zlib(3) library: .PD 0 .TP -.BI \-Z -If the -.I \-Z -option is specified, the input data will be -decompressed before searching. -.TP +.B \-Z, --decompress +Decompress the input data before searching. .PD .SH "REGULAR EXPRESSIONS" .PP @@ -251,7 +331,7 @@ Their names are self explanatory, and they are .BR [:upper:] , and .BR [:xdigit:]. -For example, +For example, .B [[:alnum:]] means .BR [0-9A-Za-z] , @@ -300,8 +380,7 @@ matches the empty string provided it's .I not at the edge of a word. .PP -A regular expression matching a single character may be followed -by one of several repetition operators: +A regular expression may be followed by one of several repetition operators: .PD 0 .TP .B ? @@ -395,7 +474,7 @@ other system errors. .SH BUGS .PP Email bug reports to -.BR bug-gnu-utils@prep.ai.mit.edu . +.BR bug-gnu-utils@gnu.org . Be sure to include the word ``grep'' somewhere in the ``Subject:'' field. .PP Large repetition counts in the |