CVSROOT: /webcvs/grep Module name: grep Changes by: Jim Meyering <meyering> 21/08/14 16:46:41
Index: html_node/Usage.html =================================================================== RCS file: /webcvs/grep/grep/manual/html_node/Usage.html,v retrieving revision 1.31 retrieving revision 1.32 diff -u -b -r1.31 -r1.32 --- html_node/Usage.html 28 Sep 2020 03:36:49 -0000 1.31 +++ html_node/Usage.html 14 Aug 2021 20:46:41 -0000 1.32 @@ -1,8 +1,11 @@ <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <html> +<!-- Created by GNU Texinfo 6.8, https://www.gnu.org/software/texinfo/ --> +<head> +<meta http-equiv="Content-Type" content="text/html; charset=utf-8"> <!-- This manual is for grep, a pattern matching engine. -Copyright (C) 1999-2002, 2005, 2008-2020 Free Software Foundation, +Copyright (C) 1999-2002, 2005, 2008-2021 Free Software Foundation, Inc. Permission is granted to copy, distribute and/or modify this document @@ -11,65 +14,55 @@ 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". --> -<!-- Created by GNU Texinfo 6.5, http://www.gnu.org/software/texinfo/ --> -<head> -<meta http-equiv="Content-Type" content="text/html; charset=utf-8"> -<title>Usage (GNU Grep 3.5)</title> +<title>Usage (GNU Grep 3.7)</title> -<meta name="description" content="Usage (GNU Grep 3.5)"> -<meta name="keywords" content="Usage (GNU Grep 3.5)"> +<meta name="description" content="Usage (GNU Grep 3.7)"> +<meta name="keywords" content="Usage (GNU Grep 3.7)"> <meta name="resource-type" content="document"> <meta name="distribution" content="global"> <meta name="Generator" content="makeinfo"> -<link href="index.html#Top" rel="start" title="Top"> -<link href="Index.html#Index" rel="index" title="Index"> +<meta name="viewport" content="width=device-width,initial-scale=1"> + +<link href="index.html" rel="start" title="Top"> +<link href="Index.html" rel="index" title="Index"> <link href="index.html#SEC_Contents" rel="contents" title="Table of Contents"> -<link href="index.html#Top" rel="up" title="Top"> -<link href="Performance.html#Performance" rel="next" title="Performance"> -<link href="Matching-Non_002dASCII.html#Matching-Non_002dASCII" rel="prev" title="Matching Non-ASCII"> +<link href="index.html" rel="up" title="Top"> +<link href="Performance.html" rel="next" title="Performance"> +<link href="Regular-Expressions.html" rel="prev" title="Regular Expressions"> <style type="text/css"> <!-- +a.copiable-anchor {visibility: hidden; text-decoration: none; line-height: 0em} a.summary-letter {text-decoration: none} blockquote.indentedblock {margin-right: 0em} -blockquote.smallindentedblock {margin-right: 0em; font-size: smaller} -blockquote.smallquotation {font-size: smaller} div.display {margin-left: 3.2em} div.example {margin-left: 3.2em} -div.lisp {margin-left: 3.2em} -div.smalldisplay {margin-left: 3.2em} -div.smallexample {margin-left: 3.2em} -div.smalllisp {margin-left: 3.2em} kbd {font-style: oblique} pre.display {font-family: inherit} pre.format {font-family: inherit} pre.menu-comment {font-family: serif} pre.menu-preformatted {font-family: serif} -pre.smalldisplay {font-family: inherit; font-size: smaller} -pre.smallexample {font-size: smaller} -pre.smallformat {font-family: inherit; font-size: smaller} -pre.smalllisp {font-size: smaller} span.nolinebreak {white-space: nowrap} span.roman {font-family: initial; font-weight: normal} span.sansserif {font-family: sans-serif; font-weight: normal} +span:hover a.copiable-anchor {visibility: visible} ul.no-bullet {list-style: none} --> </style> -<link rel="stylesheet" type="text/css" href="/software/gnulib/manual.css"> +<link rel="stylesheet" type="text/css" href="https://www.gnu.org/software/gnulib/manual.css"> </head> <body lang="en"> -<a name="Usage"></a> +<div class="chapter" id="Usage"> <div class="header"> <p> -Next: <a href="Performance.html#Performance" accesskey="n" rel="next">Performance</a>, Previous: <a href="Regular-Expressions.html#Regular-Expressions" accesskey="p" rel="prev">Regular Expressions</a>, Up: <a href="index.html#Top" accesskey="u" rel="up">Top</a> [<a href="index.html#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="Index.html#Index" title="Index" rel="index">Index</a>]</p> +Next: <a href="Performance.html" accesskey="n" rel="next">Performance</a>, Previous: <a href="Regular-Expressions.html" accesskey="p" rel="prev">Regular Expressions</a>, Up: <a href="index.html" accesskey="u" rel="up">grep</a> [<a href="index.html#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="Index.html" title="Index" rel="index">Index</a>]</p> </div> <hr> -<a name="Usage-1"></a> -<h2 class="chapter">4 Usage</h2> +<span id="Usage-1"></span><h2 class="chapter">4 Usage</h2> -<a name="index-usage_002c-examples"></a> +<span id="index-usage_002c-examples"></span> <p>Here is an example command that invokes GNU <code>grep</code>: </p> <div class="example"> @@ -79,35 +72,34 @@ <p>This lists all lines in the files <samp>menu.h</samp> and <samp>main.c</samp> that contain the string ‘<samp>hello</samp>’ followed by the string ‘<samp>world</samp>’; this is because ‘<samp>.*</samp>’ matches zero or more characters within a line. -See <a href="Regular-Expressions.html#Regular-Expressions">Regular Expressions</a>. +See <a href="Regular-Expressions.html">Regular Expressions</a>. The <samp>-i</samp> option causes <code>grep</code> to ignore case, causing it to match the line ‘<samp>Hello, world!</samp>’, which it would not otherwise match. </p> -<p>Here is a more complex example session, +<p>Here is a more complex example, showing the location and contents of any line containing ‘<samp>f</samp>’ and ending in ‘<samp>.c</samp>’, within all files in the current directory whose names -contain ‘<samp>g</samp>’ and end in ‘<samp>.h</samp>’. +start with non-‘<samp>.</samp>’, contain ‘<samp>g</samp>’, and end in ‘<samp>.h</samp>’. The <samp>-n</samp> option outputs line numbers, the <samp>--</samp> argument -treats any later arguments starting with ‘<samp>-</samp>’ as file names not -options, and the empty file <samp>/dev/null</samp> causes file names to be output +treats any later arguments as file names not options even if +<code>*g*.h</code> expands to a file name that starts with ‘<samp>-</samp>’, +and the empty file <samp>/dev/null</samp> causes file names to be output even if only one file name happens to be of the form ‘<samp>*g*.h</samp>’. </p> <div class="example"> -<pre class="example">$ <kbd>grep -n -- 'f.*\.c$' *g*.h /dev/null</kbd> -argmatch.h:1:/* definitions and prototypes for argmatch.c +<pre class="example">grep -n -- 'f.*\.c$' *g*.h /dev/null </pre></div> -<p>The only line that contains a match is line 1 of <samp>argmatch.h</samp>. -Note that the regular expression syntax used in the pattern differs +<p>Note that the regular expression syntax used in the pattern differs from the globbing syntax that the shell uses to match file names. </p> -<p>See <a href="Invoking.html#Invoking">Invoking</a>, for more details about +<p>See <a href="Invoking.html">Invoking <code>grep</code></a>, for more details about how to invoke <code>grep</code>. </p> -<a name="index-using-grep_002c-Q_0026A"></a> -<a name="index-FAQ-about-grep-usage"></a> +<span id="index-using-grep_002c-Q_0026A"></span> +<span id="index-FAQ-about-grep-usage"></span> <p>Here are some common questions and answers about <code>grep</code> usage. </p> <ol> @@ -288,11 +280,8 @@ <pre class="example">echo 'ba' | grep -E '(a)\1|b\1' </pre></div> -<p>This gives no output, because the first alternate ‘<samp>(a)\1</samp>’ does not match, -as there is no ‘<samp>aa</samp>’ in the input, so the ‘<samp>\1</samp>’ in the second alternate +<p>This outputs an error message, because the second ‘<samp>\1</samp>’ has nothing to refer back to, meaning it will never match anything. -(The second alternate in this example can only match -if the first alternate has matched—making the second one superfluous.) </p> </li><li> How can I match across lines? @@ -301,7 +290,7 @@ match newlines in the way you might expect. </p> <p>With the GNU <code>grep</code> option <samp>-z</samp> (<samp>--null-data</samp>), each -input and output “line” is null-terminated; see <a href="Other-Options.html#Other-Options">Other Options</a>. Thus, +input and output “line” is null-terminated; see <a href="Other-Options.html">Other Options</a>. Thus, you can match newlines in the input, but typically if there is a match the entire input is output, so this usage is often combined with output-suppressing options like <samp>-q</samp>, e.g.: @@ -333,10 +322,11 @@ </li></ol> +</div> <hr> <div class="header"> <p> -Next: <a href="Performance.html#Performance" accesskey="n" rel="next">Performance</a>, Previous: <a href="Regular-Expressions.html#Regular-Expressions" accesskey="p" rel="prev">Regular Expressions</a>, Up: <a href="index.html#Top" accesskey="u" rel="up">Top</a> [<a href="index.html#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="Index.html#Index" title="Index" rel="index">Index</a>]</p> +Next: <a href="Performance.html">Performance</a>, Previous: <a href="Regular-Expressions.html">Regular Expressions</a>, Up: <a href="index.html">grep</a> [<a href="index.html#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="Index.html" title="Index" rel="index">Index</a>]</p> </div>
