grep-commit
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Changes to grep/manual/html_node/Usage.html,v


From: Jim Meyering
Subject: Changes to grep/manual/html_node/Usage.html,v
Date: Fri, 02 Mar 2012 09:28:49 +0000

CVSROOT:        /webcvs/grep
Module name:    grep
Changes by:     Jim Meyering <meyering> 12/03/02 09:28:32

Index: html_node/Usage.html
===================================================================
RCS file: /webcvs/grep/grep/manual/html_node/Usage.html,v
retrieving revision 1.9
retrieving revision 1.10
diff -u -b -r1.9 -r1.10
--- html_node/Usage.html        25 Jun 2011 09:28:45 -0000      1.9
+++ html_node/Usage.html        2 Mar 2012 09:28:30 -0000       1.10
@@ -1,8 +1,8 @@
 <html lang="en">
 <head>
-<title>Usage - GNU Grep 2.9</title>
+<title>Usage - GNU Grep 2.11</title>
 <meta http-equiv="Content-Type" content="text/html">
-<meta name="description" content="GNU Grep 2.9">
+<meta name="description" content="GNU Grep 2.11">
 <meta name="generator" content="makeinfo 4.13">
 <link title="Top" rel="start" href="index.html#Top">
 <link rel="prev" href="Regular-Expressions.html#Regular-Expressions" 
title="Regular Expressions">
@@ -11,7 +11,8 @@
 <!--
 This manual is for `grep', a pattern matching engine.
 
-Copyright (C) 1999-2002, 2005, 2008-2011 Free Software Foundation, Inc.
+Copyright (C) 1999-2002, 2005, 2008-2012 Free Software Foundation,
+Inc.
 
      Permission is granted to copy, distribute and/or modify this
      document under the terms of the GNU Free Documentation License,
@@ -45,7 +46,7 @@
 
 <h2 class="chapter">4 Usage</h2>
 
-<p><a name="index-usage_002c-examples-245"></a>Here is an example command that 
invokes <span class="sc">gnu</span> <samp><span 
class="command">grep</span></samp>:
+<p><a name="index-usage_002c-examples-245"></a>Here is an example command that 
invokes GNU <samp><span class="command">grep</span></samp>:
 
 <pre class="example">     grep -i 'hello.*world' menu.h main.c
 </pre>
@@ -53,7 +54,7 @@
 contain the string &lsquo;<samp><span class="samp">hello</span></samp>&rsquo; 
followed by the string &lsquo;<samp><span 
class="samp">world</span></samp>&rsquo;;
 this is because &lsquo;<samp><span class="samp">.*</span></samp>&rsquo; 
matches zero or more characters within a line. 
 See <a href="Regular-Expressions.html#Regular-Expressions">Regular 
Expressions</a>. 
-The &lsquo;<samp><span class="samp">-i</span></samp>&rsquo; option causes 
<samp><span class="command">grep</span></samp>
+The <samp><span class="option">-i</span></samp> option causes <samp><span 
class="command">grep</span></samp>
 to ignore case, causing it to match the line &lsquo;<samp><span 
class="samp">Hello, world!</span></samp>&rsquo;, which
 it would not otherwise match. 
 See <a href="Invoking.html#Invoking">Invoking</a>, for more details about
@@ -84,13 +85,10 @@
 </pre>
      <p>This differs from the command:
 
-     <pre class="example">          grep -rH 'hello' *.c
+     <pre class="example">          grep -H 'hello' *.c
 </pre>
      <p>which merely looks for &lsquo;<samp><span 
class="samp">hello</span></samp>&rsquo; in all files in the current
 directory whose names end in &lsquo;<samp><span 
class="samp">.c</span></samp>&rsquo;. 
-Here the <samp><span class="option">-r</span></samp> is
-probably unnecessary, as recursion occurs only in the unlikely event
-that one of &lsquo;<samp><span class="samp">.c</span></samp>&rsquo; files is a 
directory. 
 The &lsquo;<samp><span class="samp">find ...</span></samp>&rsquo; command line 
above is more similar to the command:
 
      <pre class="example">          grep -rH --include='*.c' 'hello' /home/gigi
@@ -100,7 +98,7 @@
      <pre class="example">          grep -e '--cut here--' *
 </pre>
      <p class="noindent">searches for all lines matching &lsquo;<samp><span 
class="samp">--cut here--</span></samp>&rsquo;. 
-Without &lsquo;<samp><span class="samp">-e</span></samp>&rsquo;,
+Without <samp><span class="option">-e</span></samp>,
 <samp><span class="command">grep</span></samp> would attempt to parse 
&lsquo;<samp><span class="samp">--cut here--</span></samp>&rsquo; as a list of
 options.
 
@@ -135,7 +133,7 @@
 
      <pre class="example">          /etc/passwd:eli:x:2098:1000:Eli 
Smith:/home/eli:/bin/bash
 </pre>
-     <p>Alternatively, use &lsquo;<samp><span 
class="samp">-H</span></samp>&rsquo;, which is a <span class="sc">gnu</span> 
extension:
+     <p>Alternatively, use <samp><span class="option">-H</span></samp>, which 
is a GNU extension:
 
      <pre class="example">          grep -H 'eli' /etc/passwd
 </pre>
@@ -156,13 +154,13 @@
      <p>If <samp><span class="command">grep</span></samp> listed all matching 
&ldquo;lines&rdquo; from a binary file, it
 would probably generate output that is not useful, and it might even
 muck up your display. 
-So <span class="sc">gnu</span> <samp><span class="command">grep</span></samp> 
suppresses output from
+So GNU <samp><span class="command">grep</span></samp> suppresses output from
 files that appear to be binary files. 
-To force <span class="sc">gnu</span> <samp><span 
class="command">grep</span></samp>
+To force GNU <samp><span class="command">grep</span></samp>
 to output lines even from files that appear to be binary, use the
-&lsquo;<samp><span class="samp">-a</span></samp>&rsquo; or &lsquo;<samp><span 
class="samp">--binary-files=text</span></samp>&rsquo; option. 
+<samp><span class="option">-a</span></samp> or &lsquo;<samp><span 
class="samp">--binary-files=text</span></samp>&rsquo; option. 
 To eliminate the
-&ldquo;Binary file matches&rdquo; messages, use the &lsquo;<samp><span 
class="samp">-I</span></samp>&rsquo; or
+&ldquo;Binary file matches&rdquo; messages, use the <samp><span 
class="option">-I</span></samp> or
 &lsquo;<samp><span 
class="samp">--binary-files=without-match</span></samp>&rsquo; option.
 
      <li>Why doesn't &lsquo;<samp><span class="samp">grep 
-lv</span></samp>&rsquo; print non-matching file names?
@@ -170,15 +168,27 @@
      <p>&lsquo;<samp><span class="samp">grep -lv</span></samp>&rsquo; lists 
the names of all files containing one or more
 lines that do not match. 
 To list the names of all files that contain no
-matching lines, use the &lsquo;<samp><span 
class="samp">-L</span></samp>&rsquo; or &lsquo;<samp><span 
class="samp">--files-without-match</span></samp>&rsquo;
+matching lines, use the <samp><span class="option">-L</span></samp> or 
<samp><span class="option">--files-without-match</span></samp>
 option.
 
-     <li>I can do <span class="sc">or</span> with &lsquo;<samp><span 
class="samp">|</span></samp>&rsquo;, but what about <span class="sc">and</span>?
+     <li>I can do &ldquo;OR&rdquo; with &lsquo;<samp><span 
class="samp">|</span></samp>&rsquo;, but what about &ldquo;AND&rdquo;?
 
      <pre class="example">          grep 'paul' /etc/motd | grep 'franc,ois'
 </pre>
      <p class="noindent">finds all lines that contain both &lsquo;<samp><span 
class="samp">paul</span></samp>&rsquo; and &lsquo;<samp><span 
class="samp">franc,ois</span></samp>&rsquo;.
 
+     <li>Why does the empty pattern match every input line?
+
+     <p>The <samp><span class="command">grep</span></samp> command searches 
for lines that contain strings
+that match a pattern.  Every line contains the empty string, so an
+empty pattern causes <samp><span class="command">grep</span></samp> to find a 
match on each line.  It
+is not the only such pattern: &lsquo;<samp><span 
class="samp">^</span></samp>&rsquo;, &lsquo;<samp><span 
class="samp">$</span></samp>&rsquo;, &lsquo;<samp><span 
class="samp">.*</span></samp>&rsquo;, and many
+other patterns cause <samp><span class="command">grep</span></samp> to match 
every line.
+
+     <p>To match empty lines, use the pattern &lsquo;<samp><span 
class="samp">^$</span></samp>&rsquo;.  To match blank
+lines, use the pattern &lsquo;<samp><span 
class="samp">^[[:blank:]]*$</span></samp>&rsquo;.  To match no lines at
+all, use the command &lsquo;<samp><span class="samp">grep -f 
/dev/null</span></samp>&rsquo;.
+
      <li>How can I search in both standard input and in files?
 
      <p>Use the special file name &lsquo;<samp><span 
class="samp">-</span></samp>&rsquo;:
@@ -193,7 +203,7 @@
 
      <pre class="example">          grep -w -e '\(.\)\(.\).\2\1' file
 </pre>
-     <p>It matches the word "radar" or "civic".
+     <p>It matches the word &ldquo;radar&rdquo; or &ldquo;civic.&rdquo;
 
      <p>Guglielmo Bondioni proposed a single RE
 that finds all palindromes up to 19 characters long
@@ -201,7 +211,7 @@
 
      <pre class="smallexample">          grep -E -e 
'^(.?)(.?)(.?)(.?)(.?)(.?)(.?)(.?)(.?).?\9\8\7\6\5\4\3\2\1$' file
 </pre>
-     <p>Note this is done by using <span class="sc">gnu</span> ERE extensions;
+     <p>Note this is done by using GNU ERE extensions;
 it might not be portable to other implementations of <samp><span 
class="command">grep</span></samp>.
 
      <li>Why is this back-reference failing?



reply via email to

[Prev in Thread] Current Thread [Next in Thread]