CVSROOT: /web/grep Module name: grep Changes by: Karl Berry <karl> 09/05/24 18:43:01
Index: manual/html_node/General-Output-Control.html =================================================================== RCS file: manual/html_node/General-Output-Control.html diff -N manual/html_node/General-Output-Control.html --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ manual/html_node/General-Output-Control.html 24 May 2009 18:42:59 -0000 1.1 @@ -0,0 +1,141 @@ +<html lang="en"> +<head> +<title>General Output Control - GNU Grep 2.5.4</title> +<meta http-equiv="Content-Type" content="text/html"> +<meta name="description" content="GNU Grep 2.5.4"> +<meta name="generator" content="makeinfo 4.13"> +<link title="Top" rel="start" href="index.html#Top"> +<link rel="up" href="Command_002dline-Options.html#Command_002dline-Options" title="Command-line Options"> +<link rel="prev" href="Matching-Control.html#Matching-Control" title="Matching Control"> +<link rel="next" href="Output-Line-Prefix-Control.html#Output-Line-Prefix-Control" title="Output Line Prefix Control"> +<link href="http://www.gnu.org/software/texinfo/" rel="generator-home" title="Texinfo Homepage"> +<!-- +This manual is for `grep', a pattern matching engine. + +Copyright (C) 1999, 2000, 2001, 2002, 2005, 2008, 2009 Free +Software Foundation, Inc. + + Permission is granted to copy, distribute and/or modify this + document under the terms of the GNU Free Documentation License, + Version 1.3 or any later version published by the Free Software + Foundation; with no Invariant Sections, with no Front-Cover Texts, + and with no Back-Cover Texts. A copy of the license is included + in the section entitled ``GNU Free Documentation License''. + --> +<meta http-equiv="Content-Style-Type" content="text/css"> +<style type="text/css"><!-- + pre.display { font-family:inherit } + pre.format { font-family:inherit } + pre.smalldisplay { font-family:inherit; font-size:smaller } + pre.smallformat { font-family:inherit; font-size:smaller } + pre.smallexample { font-size:smaller } + pre.smalllisp { font-size:smaller } + span.sc { font-variant:small-caps } + span.roman { font-family:serif; font-weight:normal; } + span.sansserif { font-family:sans-serif; font-weight:normal; } +--></style> +</head> +<body> +<div class="node"> +<a name="General-Output-Control"></a> +<p> +Next: <a rel="next" accesskey="n" href="Output-Line-Prefix-Control.html#Output-Line-Prefix-Control">Output Line Prefix Control</a>, +Previous: <a rel="previous" accesskey="p" href="Matching-Control.html#Matching-Control">Matching Control</a>, +Up: <a rel="up" accesskey="u" href="Command_002dline-Options.html#Command_002dline-Options">Command-line Options</a> +<hr> +</div> + +<h4 class="subsection">2.1.3 General Output Control</h4> + + <dl> +<dt>‘<samp><span class="samp">-c</span></samp>’<dt>‘<samp><span class="samp">--count</span></samp>’<dd><a name="index-g_t_002dc-27"></a><a name="index-g_t_002d_002dcount-28"></a><a name="index-counting-lines-29"></a>Suppress normal output; +instead print a count of matching lines for each input file. +With the ‘<samp><span class="samp">-v</span></samp>’, ‘<samp><span class="samp">--invert-match</span></samp>’ option, +count non-matching lines. +(‘<samp><span class="samp">-c</span></samp>’ is specified by <span class="sc">posix</span>.) + + <br><dt>‘<samp><span class="samp">--color[=</span><var>WHEN</var><span class="samp">]</span></samp>’<dt>‘<samp><span class="samp">--colour[=</span><var>WHEN</var><span class="samp">]</span></samp>’<dd><a name="index-g_t_002d_002dcolor-30"></a><a name="index-g_t_002d_002dcolour-31"></a><a name="index-highlight_002c-color_002c-colour-32"></a>Surround the matched (non-empty) strings, matching lines, context lines, +file names, line numbers, byte offsets, and separators (for fields and +groups of context lines) with escape sequences to display them in color +on the terminal. +The colors are defined by the environment variable <var>GREP_COLORS</var> +and default to ‘<samp><span class="samp">ms=01;31:mc=01;31:sl=:cx=:fn=35:ln=32:bn=32:se=36</span></samp>’ +for bold red matched text, magenta file names, green line numbers, +green byte offsets, cyan separators, and default terminal colors otherwise. +The deprecated environment variable <var>GREP_COLOR</var> is still supported, +but its setting does not have priority; +it defaults to `01;31' (bold red) +which only covers the color for matched text. +<var>WHEN</var> is ‘<samp><span class="samp">never</span></samp>’, ‘<samp><span class="samp">always</span></samp>’, or ‘<samp><span class="samp">auto</span></samp>’. + + <br><dt>‘<samp><span class="samp">-L</span></samp>’<dt>‘<samp><span class="samp">--files-without-match</span></samp>’<dd><a name="index-g_t_002dL-33"></a><a name="index-g_t_002d_002dfiles_002dwithout_002dmatch-34"></a><a name="index-files-which-don_0027t-match-35"></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. + + <br><dt>‘<samp><span class="samp">-l</span></samp>’<dt>‘<samp><span class="samp">--files-with-matches</span></samp>’<dd><a name="index-g_t_002dl-36"></a><a name="index-g_t_002d_002dfiles_002dwith_002dmatches-37"></a><a name="index-names-of-matching-files-38"></a>Suppress normal output; +instead print the name of each input file from which +output would normally have been printed. +The scanning of every file will stop on the first match. +(‘<samp><span class="samp">-l</span></samp>’ is specified by <span class="sc">posix</span>.) + + <br><dt>‘<samp><span class="samp">-m </span><var>num</var></samp>’<dt>‘<samp><span class="samp">--max-count=</span><var>num</var></samp>’<dd><a name="index-g_t_002dm-39"></a><a name="index-g_t_002d_002dmax_002dcount-40"></a><a name="index-max_002dcount-41"></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, +<samp><span class="command">grep</span></samp> ensures that the standard input is positioned +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: + + <pre class="example"> while grep -m 1 PATTERN + do + echo xxxx + done < FILE +</pre> + <p>But the following probably will not work because a pipe is not a regular +file: + + <pre class="example"> # This probably will not work. + cat FILE | + while grep -m 1 PATTERN + do + echo xxxx + done +</pre> + <p>When <samp><span class="command">grep</span></samp> stops after <var>num</var> matching lines, +it outputs any trailing context lines. +Since context does not include matching lines, +<samp><span class="command">grep</span></samp> will stop when it encounters another matching line. +When the ‘<samp><span class="samp">-c</span></samp>’ or ‘<samp><span class="samp">--count</span></samp>’ option is also used, +<samp><span class="command">grep</span></samp> does not output a count greater than <var>num</var>. +When the ‘<samp><span class="samp">-v</span></samp>’ or ‘<samp><span class="samp">--invert-match</span></samp>’ option is also used, +<samp><span class="command">grep</span></samp> stops after outputting <var>num</var> non-matching lines. + + <br><dt>‘<samp><span class="samp">-o</span></samp>’<dt>‘<samp><span class="samp">--only-matching</span></samp>’<dd><a name="index-g_t_002do-42"></a><a name="index-g_t_002d_002donly_002dmatching-43"></a><a name="index-only-matching-44"></a>Print only the matched (non-empty) parts of matching lines, +with each such part on a separate output line. + + <br><dt>‘<samp><span class="samp">-q</span></samp>’<dt>‘<samp><span class="samp">--quiet</span></samp>’<dt>‘<samp><span class="samp">--silent</span></samp>’<dd><a name="index-g_t_002dq-45"></a><a name="index-g_t_002d_002dquiet-46"></a><a name="index-g_t_002d_002dsilent-47"></a><a name="index-quiet_002c-silent-48"></a>Quiet; do not write anything to standard output. +Exit immediately with zero status if any match is found, +even if an error was detected. +Also see the ‘<samp><span class="samp">-s</span></samp>’ or ‘<samp><span class="samp">--no-messages</span></samp>’ option. +(‘<samp><span class="samp">-q</span></samp>’ is specified by <span class="sc">posix</span>.) + + <br><dt>‘<samp><span class="samp">-s</span></samp>’<dt>‘<samp><span class="samp">--no-messages</span></samp>’<dd><a name="index-g_t_002ds-49"></a><a name="index-g_t_002d_002dno_002dmessages-50"></a><a name="index-suppress-error-messages-51"></a>Suppress error messages about nonexistent or unreadable files. +Portability note: +unlike <span class="sc">gnu</span> <samp><span class="command">grep</span></samp>, +7th Edition Unix <samp><span class="command">grep</span></samp> did not conform to <span class="sc">posix</span>, +because it lacked ‘<samp><span class="samp">-q</span></samp>’ +and its ‘<samp><span class="samp">-s</span></samp>’ option behaved like +<span class="sc">gnu</span> <samp><span class="command">grep</span></samp>'s ‘<samp><span class="samp">-q</span></samp>’ option. +<span class="sc">usg</span>-style <samp><span class="command">grep</span></samp> also lacked ‘<samp><span class="samp">-q</span></samp>’ +but its ‘<samp><span class="samp">-s</span></samp>’ option behaved like <span class="sc">gnu</span> <samp><span class="command">grep</span></samp>'s. +Portable shell scripts should avoid both +‘<samp><span class="samp">-q</span></samp>’ and ‘<samp><span class="samp">-s</span></samp>’ and should redirect +standard and error output to <samp><span class="file">/dev/null</span></samp> instead. +(‘<samp><span class="samp">-s</span></samp>’ is specified by <span class="sc">posix</span>.) + +</dl> + + </body></html> +
