CVSROOT: /web/grep Module name: grep Changes by: Karl Berry <karl> 09/05/24 18:43:01
Index: doc/grep_3.html =================================================================== RCS file: doc/grep_3.html diff -N doc/grep_3.html --- doc/grep_3.html 23 Jan 2002 10:33:52 -0000 1.3 +++ /dev/null 1 Jan 1970 00:00:00 -0000 @@ -1,399 +0,0 @@ -<HTML> -<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> -<!-- Created on January, 23 2002 by texi2html 1.64 --> -<!-- -Written by: Lionel Cons <[email protected]> (original author) - Karl Berry <[email protected]> - Olaf Bachmann <[email protected]> - and many others. -Maintained by: Olaf Bachmann <[email protected]> -Send bugs and suggestions to <[email protected]> - ---> -<HEAD> -<TITLE>grep, print lines matching a pattern: 2.1 GNU Extensions</TITLE> - -<META NAME="description" CONTENT="grep, print lines matching a pattern: 2.1 GNU Extensions"> -<META NAME="keywords" CONTENT="grep, print lines matching a pattern: 2.1 GNU Extensions"> -<META NAME="resource-type" CONTENT="document"> -<META NAME="distribution" CONTENT="global"> -<META NAME="Generator" CONTENT="texi2html 1.64"> - -</HEAD> - -<BODY LANG="" BGCOLOR="#FFFFFF" TEXT="#000000" LINK="#0000FF" VLINK="#800080" ALINK="#FF0000"> - -<A NAME="SEC3"></A> -<TABLE CELLPADDING=1 CELLSPACING=1 BORDER=0> -<TR><TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="grep_2.html#SEC2"> < </A>]</TD> -<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="grep_4.html#SEC4"> > </A>]</TD> -<TD VALIGN="MIDDLE" ALIGN="LEFT"> <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="grep_2.html#SEC2"> << </A>]</TD> -<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="grep_2.html#SEC2"> Up </A>]</TD> -<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="grep_5.html#SEC5"> >> </A>]</TD> -<TD VALIGN="MIDDLE" ALIGN="LEFT"> <TD VALIGN="MIDDLE" ALIGN="LEFT"> <TD VALIGN="MIDDLE" ALIGN="LEFT"> <TD VALIGN="MIDDLE" ALIGN="LEFT"> <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="grep.html#SEC_Top">Top</A>]</TD> -<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="grep_toc.html#SEC_Contents">Contents</A>]</TD> -<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="grep_21.html#SEC21">Index</A>]</TD> -<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="grep_abt.html#SEC_About"> ? </A>]</TD> -</TR></TABLE> -<HR SIZE=1> -<H2> 2.1 GNU Extensions </H2> -<!--docid::SEC3::--> -<P> - -<DL COMPACT> - -<DT><SAMP>`-A <VAR>num</VAR>'</SAMP> -<DD><DT><SAMP>`--after-context=<VAR>num</VAR>'</SAMP> -<DD><A NAME="IDX37"></A> -<A NAME="IDX38"></A> -<A NAME="IDX39"></A> -<A NAME="IDX40"></A> -Print <VAR>num</VAR> lines of trailing context after matching lines. -<P> - -<DT><SAMP>`-B <VAR>num</VAR>'</SAMP> -<DD><DT><SAMP>`--before-context=<VAR>num</VAR>'</SAMP> -<DD><A NAME="IDX41"></A> -<A NAME="IDX42"></A> -<A NAME="IDX43"></A> -<A NAME="IDX44"></A> -Print <VAR>num</VAR> lines of leading context before matching lines. -<P> - -<DT><SAMP>`-C <VAR>num</VAR>'</SAMP> -<DD><DT><SAMP>`--context=<VAR>num</VAR>'</SAMP> -<DD><A NAME="IDX45"></A> -<A NAME="IDX46"></A> -<A NAME="IDX47"></A> -Print <VAR>num</VAR> lines of output context. -<P> - -<DT><SAMP>`--colour[=<VAR>WHEN</VAR>]'</SAMP> -<DD><DT><SAMP>`--color[=<VAR>WHEN</VAR>]'</SAMP> -<DD><A NAME="IDX48"></A> -<A NAME="IDX49"></A> -The matching string is surrounded by the marker specify in <VAR>GREP_COLOR</VAR>. -<VAR>WHEN</VAR> may be `never', `always', or `auto'. -<P> - -<DT><SAMP>`-<VAR>num</VAR>'</SAMP> -<DD><A NAME="IDX50"></A> -Same as <SAMP>`--context=<VAR>num</VAR>'</SAMP> lines of leading and trailing -context. However, grep will never print any given line more than once. -<P> - -<DT><SAMP>`-V'</SAMP> -<DD><DT><SAMP>`--version'</SAMP> -<DD><A NAME="IDX51"></A> -<A NAME="IDX52"></A> -<A NAME="IDX53"></A> -Print the version number of <CODE>grep</CODE> to the standard output stream. -This version number should be included in all bug reports. -<P> - -<DT><SAMP>`--help'</SAMP> -<DD><A NAME="IDX54"></A> -<A NAME="IDX55"></A> -Print a usage message briefly summarizing these command-line options -and the bug-reporting address, then exit. -<P> - -<DT><SAMP>`--binary-files=<VAR>type</VAR>'</SAMP> -<DD><A NAME="IDX56"></A> -<A NAME="IDX57"></A> -If the first few bytes of a file indicate that the file contains binary -data, assume that the file is of type <VAR>type</VAR>. By default, -<VAR>type</VAR> is <SAMP>`binary'</SAMP>, and <CODE>grep</CODE> normally outputs either -a one-line message saying that a binary file matches, or no message if -there is no match. If <VAR>type</VAR> is <SAMP>`without-match'</SAMP>, -<CODE>grep</CODE> assumes that a binary file does not match; -this is equivalent to the <SAMP>`-I'</SAMP> option. If <VAR>type</VAR> -is <SAMP>`text'</SAMP>, <CODE>grep</CODE> processes a binary file as if it were -text; this is equivalent to the <SAMP>`-a'</SAMP> option. -<EM>Warning:</EM> <SAMP>`--binary-files=text'</SAMP> might output binary garbage, -which can have nasty side effects if the output is a terminal and if the -terminal driver interprets some of it as commands. -<P> - -<DT><SAMP>`-b'</SAMP> -<DD><DT><SAMP>`--byte-offset'</SAMP> -<DD><A NAME="IDX58"></A> -<A NAME="IDX59"></A> -<A NAME="IDX60"></A> -Print the byte offset within the input file before each line of output. -When <CODE>grep</CODE> runs on MS-DOS or MS-Windows, the printed -byte offsets -depend on whether the <SAMP>`-u'</SAMP> (<SAMP>`--unix-byte-offsets'</SAMP>) option is -used; see below. -<P> - -<DT><SAMP>`-D <VAR>action</VAR>'</SAMP> -<DD><DT><SAMP>`--devices=<VAR>action</VAR>'</SAMP> -<DD><A NAME="IDX61"></A> -<A NAME="IDX62"></A> -<A NAME="IDX63"></A> -If an input file is a device, FIFO or socket, use <VAR>action</VAR> to process it. -By default, <VAR>action</VAR> is <SAMP>`read'</SAMP>, which means that devices are -read just as if they were ordinary files. -If <VAR>action</VAR> is <SAMP>`skip'</SAMP>, devices, FIFOs and sockets are silently -skipped. -<P> - -<DT><SAMP>`-d <VAR>action</VAR>'</SAMP> -<DD><DT><SAMP>`--directories=<VAR>action</VAR>'</SAMP> -<DD><A NAME="IDX64"></A> -<A NAME="IDX65"></A> -<A NAME="IDX66"></A> -If an input file is a directory, use <VAR>action</VAR> to process it. -By default, <VAR>action</VAR> is <SAMP>`read'</SAMP>, which means that directories are -read just as if they were ordinary files (some operating systems -and filesystems disallow this, and will cause <CODE>grep</CODE> to print error -messages for every directory or silently skip them). If <VAR>action</VAR> is -<SAMP>`skip'</SAMP>, directories are silently skipped. If <VAR>action</VAR> is -<SAMP>`recurse'</SAMP>, <CODE>grep</CODE> reads all files under each directory, -recursively; this is equivalent to the <SAMP>`-r'</SAMP> option. -<P> - -<DT><SAMP>`-H'</SAMP> -<DD><DT><SAMP>`--with-filename'</SAMP> -<DD><A NAME="IDX67"></A> -<A NAME="IDX68"></A> -<A NAME="IDX69"></A> -Print the filename for each match. -<P> - -<DT><SAMP>`-h'</SAMP> -<DD><DT><SAMP>`--no-filename'</SAMP> -<DD><A NAME="IDX70"></A> -<A NAME="IDX71"></A> -<A NAME="IDX72"></A> -Suppress the prefixing of filenames on output when multiple files are searched. -<P> - -<DT><SAMP>`--line-buffered'</SAMP> -<DD><A NAME="IDX73"></A> -<A NAME="IDX74"></A> -Set the line buffering policy, this can be a performance penality. -<P> - -<DT><SAMP>`--label=<VAR>LABEL</VAR>'</SAMP> -<DD><A NAME="IDX75"></A> -<A NAME="IDX76"></A> -Displays input actually coming from standard input as input coming from file -<VAR>LABEL</VAR>. This is especially useful for tools like zgrep, e.g. -<CODE>gzip -cd foo.gz |grep --label=foo something</CODE> -<P> - -<DT><SAMP>`-L'</SAMP> -<DD><DT><SAMP>`--files-without-match'</SAMP> -<DD><A NAME="IDX77"></A> -<A NAME="IDX78"></A> -<A NAME="IDX79"></A> -Suppress normal output; instead print the name of each input -file from which no output would normally have been printed. -The scanning of every file will stop on the first match. -<P> - -<DT><SAMP>`-a'</SAMP> -<DD><DT><SAMP>`--text'</SAMP> -<DD><A NAME="IDX80"></A> -<A NAME="IDX81"></A> -<A NAME="IDX82"></A> -<A NAME="IDX83"></A> -Process a binary file as if it were text; this is equivalent to the -<SAMP>`--binary-files=text'</SAMP> option. -<P> - -<DT><SAMP>`-I'</SAMP> -<DD>Process a binary file as if it did not contain matching data; this is -equivalent to the <SAMP>`--binary-files=without-match'</SAMP> option. -<P> - -<DT><SAMP>`-w'</SAMP> -<DD><DT><SAMP>`--word-regexp'</SAMP> -<DD><A NAME="IDX84"></A> -<A NAME="IDX85"></A> -<A NAME="IDX86"></A> -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 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. -<P> - -<DT><SAMP>`-r'</SAMP> -<DD><DT><SAMP>`-R'</SAMP> -<DD><DT><SAMP>`--recursive'</SAMP> -<DD><A NAME="IDX87"></A> -<A NAME="IDX88"></A> -<A NAME="IDX89"></A> -<A NAME="IDX90"></A> -For each directory mentioned in the command line, read and process all -files in that directory, recursively. This is the same as the -<SAMP>`--directories=recurse'</SAMP> option. -<P> - -<DT><SAMP>`--include=<VAR>file_pattern</VAR>'</SAMP> -<DD><A NAME="IDX91"></A> -<A NAME="IDX92"></A> -<A NAME="IDX93"></A> -When processing directories recursively, only files matching <VAR>file_pattern</VAR> -will be search. -<P> - -<DT><SAMP>`--exclude=<VAR>file_pattern</VAR>'</SAMP> -<DD><A NAME="IDX94"></A> -<A NAME="IDX95"></A> -<A NAME="IDX96"></A> -When processing directories recursively, skip files matching <VAR>file_pattern</VAR>. -<P> - -<DT><SAMP>`-m <VAR>num</VAR>'</SAMP> -<DD><DT><SAMP>`--max-count=<VAR>num</VAR>'</SAMP> -<DD><A NAME="IDX97"></A> -<A NAME="IDX98"></A> -<A NAME="IDX99"></A> -Stop reading a file after <VAR>num</VAR> matching lines. If the input is -standard input from a regular file, and <VAR>num</VAR> matching lines are -output, <CODE>grep</CODE> ensures that the standard input is positioned to -just after the last matching line before exiting, regardless of the -presence of trailing context lines. This enables a calling process -to resume a search. For example, the following shell script makes use -of it: -<P> - -<TABLE><tr><td> </td><td class=example><pre>while grep -m 1 PATTERN -do - echo xxxx -done < FILE -</pre></td></tr></table></P><P> - -But the following probably will not work because a pipe is not a regular -file: -</P><P> - -<TABLE><tr><td> </td><td class=example><pre># This probably will not work. -cat FILE | -while grep -m 1 PATTERN -do - echo xxxx -done -</pre></td></tr></table></P><P> - -When <CODE>grep</CODE> stops after NUM matching lines, it outputs -any trailing context lines. Since context does not include matching -lines, <CODE>grep</CODE> will stop when it encounters another matching line. -When the <SAMP>`-c'</SAMP> or <SAMP>`--count'</SAMP> option is also used, -<CODE>grep</CODE> does not output a count greater than <VAR>num</VAR>. -When the <SAMP>`-v'</SAMP> or <SAMP>`--invert-match'</SAMP> option is -also used, <CODE>grep</CODE> stops after outputting <VAR>num</VAR> -non-matching lines. -</P><P> - -<DT><SAMP>`-y'</SAMP> -<DD><A NAME="IDX100"></A> -<A NAME="IDX101"></A> -Obsolete synonym for <SAMP>`-i'</SAMP>. -<P> - -<DT><SAMP>`-U'</SAMP> -<DD><DT><SAMP>`--binary'</SAMP> -<DD><A NAME="IDX102"></A> -<A NAME="IDX103"></A> -<A NAME="IDX104"></A> -<A NAME="IDX105"></A> -Treat the file(s) as binary. By default, under MS-DOS -and MS-Windows, <CODE>grep</CODE> guesses the file type by looking -at the contents of the first 32kB read from the file. -If <CODE>grep</CODE> decides the file is a text file, it strips the -<CODE>CR</CODE> characters from the original file contents (to make -regular expressions with <CODE>^</CODE> and <CODE>$</CODE> work correctly). -Specifying <SAMP>`-U'</SAMP> overrules this guesswork, causing all -files to be read and passed to the matching mechanism -verbatim; if the file is a text file with <CODE>CR/LF</CODE> pairs -at the end of each line, this will cause some regular -expressions to fail. This option has no effect on platforms other than -MS-DOS and MS-Windows. -<P> - -<DT><SAMP>`-u'</SAMP> -<DD><DT><SAMP>`--unix-byte-offsets'</SAMP> -<DD><A NAME="IDX106"></A> -<A NAME="IDX107"></A> -<A NAME="IDX108"></A> -<A NAME="IDX109"></A> -Report Unix-style byte offsets. This switch causes -<CODE>grep</CODE> to report byte offsets as if the file were Unix style -text file, i.e., the byte offsets ignore the <CODE>CR</CODE> characters which were -stripped. This will produce results identical to running <CODE>grep</CODE> on -a Unix machine. This option has no effect unless <SAMP>`-b'</SAMP> -option is also used; it has no effect on platforms other than MS-DOS and -MS-Windows. -<P> - -<DT><SAMP>`--mmap'</SAMP> -<DD><A NAME="IDX110"></A> -<A NAME="IDX111"></A> -If possible, use the <CODE>mmap</CODE> system call to read input, instead of -the default <CODE>read</CODE> system call. In some situations, <SAMP>`--mmap'</SAMP> -yields better performance. However, <SAMP>`--mmap'</SAMP> can cause undefined -behavior (including core dumps) if an input file shrinks while -<CODE>grep</CODE> is operating, or if an I/O error occurs. -<P> - -<DT><SAMP>`-Z'</SAMP> -<DD><DT><SAMP>`--null'</SAMP> -<DD><A NAME="IDX112"></A> -<A NAME="IDX113"></A> -<A NAME="IDX114"></A> -Output a zero byte (the ASCII <CODE>NUL</CODE> character) instead of the -character that normally follows a file name. For example, <SAMP>`grep --lZ'</SAMP> outputs a zero byte after each file name instead of the usual -newline. This option makes the output unambiguous, even in the presence -of file names containing unusual characters like newlines. This option -can be used with commands like <SAMP>`find -print0'</SAMP>, <SAMP>`perl -0'</SAMP>, -<SAMP>`sort -z'</SAMP>, and <SAMP>`xargs -0'</SAMP> to process arbitrary file names, -even those that contain newline characters. -<P> - -<DT><SAMP>`-z'</SAMP> -<DD><DT><SAMP>`--null-data'</SAMP> -<DD><A NAME="IDX115"></A> -<A NAME="IDX116"></A> -<A NAME="IDX117"></A> -Treat the input as a set of lines, each terminated by a zero byte (the -ASCII <CODE>NUL</CODE> character) instead of a newline. Like the <SAMP>`-Z'</SAMP> -or <SAMP>`--null'</SAMP> option, this option can be used with commands like -<SAMP>`sort -z'</SAMP> to process arbitrary file names. -<P> - -</DL> -<P> - -Several additional options control which variant of the <CODE>grep</CODE> -matching engine is used. See section <A HREF="grep_6.html#SEC6">4. <CODE>grep</CODE> programs</A>. -</P><P> - -<HR SIZE=1> -<TABLE CELLPADDING=1 CELLSPACING=1 BORDER=0> -<TR><TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="grep_2.html#SEC2"> < </A>]</TD> -<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="grep_4.html#SEC4"> > </A>]</TD> -<TD VALIGN="MIDDLE" ALIGN="LEFT"> <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="grep_2.html#SEC2"> << </A>]</TD> -<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="grep_2.html#SEC2"> Up </A>]</TD> -<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="grep_5.html#SEC5"> >> </A>]</TD> -<TD VALIGN="MIDDLE" ALIGN="LEFT"> <TD VALIGN="MIDDLE" ALIGN="LEFT"> <TD VALIGN="MIDDLE" ALIGN="LEFT"> <TD VALIGN="MIDDLE" ALIGN="LEFT"> <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="grep.html#SEC_Top">Top</A>]</TD> -<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="grep_toc.html#SEC_Contents">Contents</A>]</TD> -<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="grep_21.html#SEC21">Index</A>]</TD> -<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="grep_abt.html#SEC_About"> ? </A>]</TD> -</TR></TABLE> -<BR> -<FONT SIZE="-1"> -This document was generated -by <I>root</I> on <I>January, 23 2002</I> -using <A HREF="http://www.mathematik.uni-kl.de/~obachman/Texi2html -"><I>texi2html</I></A> - -</BODY> -</HTML>
