[Top][All Lists]
[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 ‘<samp><span class="samp">hello</span></samp>’
followed by the string ‘<samp><span
class="samp">world</span></samp>’;
this is because ‘<samp><span class="samp">.*</span></samp>’
matches zero or more characters within a line.
See <a href="Regular-Expressions.html#Regular-Expressions">Regular
Expressions</a>.
-The ‘<samp><span class="samp">-i</span></samp>’ 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 ‘<samp><span
class="samp">Hello, world!</span></samp>’, 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 ‘<samp><span
class="samp">hello</span></samp>’ in all files in the current
directory whose names end in ‘<samp><span
class="samp">.c</span></samp>’.
-Here the <samp><span class="option">-r</span></samp> is
-probably unnecessary, as recursion occurs only in the unlikely event
-that one of ‘<samp><span class="samp">.c</span></samp>’ files is a
directory.
The ‘<samp><span class="samp">find ...</span></samp>’ 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 ‘<samp><span
class="samp">--cut here--</span></samp>’.
-Without ‘<samp><span class="samp">-e</span></samp>’,
+Without <samp><span class="option">-e</span></samp>,
<samp><span class="command">grep</span></samp> would attempt to parse
‘<samp><span class="samp">--cut here--</span></samp>’ 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 ‘<samp><span
class="samp">-H</span></samp>’, 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
“lines” 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
-‘<samp><span class="samp">-a</span></samp>’ or ‘<samp><span
class="samp">--binary-files=text</span></samp>’ option.
+<samp><span class="option">-a</span></samp> or ‘<samp><span
class="samp">--binary-files=text</span></samp>’ option.
To eliminate the
-“Binary file matches” messages, use the ‘<samp><span
class="samp">-I</span></samp>’ or
+“Binary file matches” messages, use the <samp><span
class="option">-I</span></samp> or
‘<samp><span
class="samp">--binary-files=without-match</span></samp>’ option.
<li>Why doesn't ‘<samp><span class="samp">grep
-lv</span></samp>’ print non-matching file names?
@@ -170,15 +168,27 @@
<p>‘<samp><span class="samp">grep -lv</span></samp>’ 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 ‘<samp><span
class="samp">-L</span></samp>’ or ‘<samp><span
class="samp">--files-without-match</span></samp>’
+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 ‘<samp><span
class="samp">|</span></samp>’, but what about <span class="sc">and</span>?
+ <li>I can do “OR” with ‘<samp><span
class="samp">|</span></samp>’, but what about “AND”?
<pre class="example"> grep 'paul' /etc/motd | grep 'franc,ois'
</pre>
<p class="noindent">finds all lines that contain both ‘<samp><span
class="samp">paul</span></samp>’ and ‘<samp><span
class="samp">franc,ois</span></samp>’.
+ <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: ‘<samp><span
class="samp">^</span></samp>’, ‘<samp><span
class="samp">$</span></samp>’, ‘<samp><span
class="samp">.*</span></samp>’, and many
+other patterns cause <samp><span class="command">grep</span></samp> to match
every line.
+
+ <p>To match empty lines, use the pattern ‘<samp><span
class="samp">^$</span></samp>’. To match blank
+lines, use the pattern ‘<samp><span
class="samp">^[[:blank:]]*$</span></samp>’. To match no lines at
+all, use the command ‘<samp><span class="samp">grep -f
/dev/null</span></samp>’.
+
<li>How can I search in both standard input and in files?
<p>Use the special file name ‘<samp><span
class="samp">-</span></samp>’:
@@ -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 “radar” or “civic.”
<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?
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- Changes to grep/manual/html_node/Usage.html,v,
Jim Meyering <=