[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, 05 Feb 2016 00:45:06 +0000 |
CVSROOT: /webcvs/grep
Module name: grep
Changes by: Jim Meyering <meyering> 16/02/05 00:44:53
Index: html_node/Usage.html
===================================================================
RCS file: /webcvs/grep/grep/manual/html_node/Usage.html,v
retrieving revision 1.21
retrieving revision 1.22
diff -u -b -r1.21 -r1.22
--- html_node/Usage.html 2 Nov 2015 02:54:36 -0000 1.21
+++ html_node/Usage.html 5 Feb 2016 00:44:53 -0000 1.22
@@ -1,263 +1,340 @@
-<html lang="en">
+<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
+<html>
+<!-- This manual is for grep, a pattern matching engine.
+
+Copyright (C) 1999-2002, 2005, 2008-2016 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". -->
+<!-- Created by GNU Texinfo 6.0, http://www.gnu.org/software/texinfo/ -->
<head>
-<title>Usage - GNU Grep 2.22</title>
+<title>GNU Grep 2.23: Usage</title>
+
+<meta name="description" content="GNU Grep 2.23: Usage">
+<meta name="keywords" content="GNU Grep 2.23: Usage">
+<meta name="resource-type" content="document">
+<meta name="distribution" content="global">
+<meta name="Generator" content="makeinfo">
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
-<meta name="description" content="GNU Grep 2.22">
-<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">
-<link rel="next" href="Reporting-Bugs.html#Reporting-Bugs" title="Reporting
Bugs">
-<link href="http://www.gnu.org/software/texinfo/" rel="generator-home"
title="Texinfo Homepage">
+<link href="index.html#Top" rel="start" title="Top">
+<link href="Index.html#Index" 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="Reporting-Bugs.html#Reporting-Bugs" rel="next" title="Reporting
Bugs">
+<link href="Basic-vs-Extended.html#Basic-vs-Extended" rel="prev" title="Basic
vs Extended">
+<style type="text/css">
<!--
-This manual is for `grep', a pattern matching engine.
+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.nocodebreak {white-space: nowrap}
+span.nolinebreak {white-space: nowrap}
+span.roman {font-family: serif; font-weight: normal}
+span.sansserif {font-family: sans-serif; font-weight: normal}
+ul.no-bullet {list-style: none}
+-->
+</style>
+<link rel="stylesheet" type="text/css" href="/software/gnulib/manual.css">
-Copyright (C) 1999-2002, 2005, 2008-2015 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>
-<link rel="stylesheet" type="text/css" href="/software/gnulib/manual.css">
</head>
-<body>
-<div class="node">
+
+<body lang="en">
<a name="Usage"></a>
+<div class="header">
<p>
-Next: <a rel="next" accesskey="n"
href="Reporting-Bugs.html#Reporting-Bugs">Reporting Bugs</a>,
-Previous: <a rel="previous" accesskey="p"
href="Regular-Expressions.html#Regular-Expressions">Regular Expressions</a>,
-Up: <a rel="up" accesskey="u" href="index.html#Top">Top</a>
-<hr>
+Next: <a href="Reporting-Bugs.html#Reporting-Bugs" accesskey="n"
rel="next">Reporting Bugs</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>
</div>
-
+<hr>
+<a name="Usage-1"></a>
<h2 class="chapter">4 Usage</h2>
-<p><a name="index-usage_002c-examples-255"></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>
- <p class="noindent">This lists all lines in the files <samp><span
class="file">menu.h</span></samp> and <samp><span
class="file">main.c</span></samp> that
-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.
+<a name="index-usage_002c-examples"></a>
+<p>Here is an example command that invokes GNU <code>grep</code>:
+</p>
+<div class="example">
+<pre class="example">grep -i 'hello.*world' menu.h main.c
+</pre></div>
+
+<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>.
-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
+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.
See <a href="Invoking.html#Invoking">Invoking</a>, for more details about
-how to invoke <samp><span class="command">grep</span></samp>.
-
- <p><a name="index-using-_0040command_007bgrep_007d_002c-Q_0026A-256"></a><a
name="index-FAQ-about-_0040command_007bgrep_007d-usage-257"></a>Here are some
common questions and answers about <samp><span
class="command">grep</span></samp> usage.
-
- <ol type=1 start=1>
-
- <li>How can I list just the names of matching files?
+how to invoke <code>grep</code>.
+</p>
+<a name="index-using-grep_002c-Q_0026A"></a>
+<a name="index-FAQ-about-grep-usage"></a>
+<p>Here are some common questions and answers about <code>grep</code> usage.
+</p>
+<ol>
+<li> How can I list just the names of matching files?
+
+<div class="example">
+<pre class="example">grep -l 'main' *.c
+</pre></div>
+
+<p>lists the names of all C files in the current directory whose contents
+mention ‘<samp>main</samp>’.
+</p>
+</li><li> How do I search directories recursively?
+
+<div class="example">
+<pre class="example">grep -r 'hello' /home/gigi
+</pre></div>
- <pre class="example"> grep -l 'main' *.c
-</pre>
- <p class="noindent">lists the names of all C files in the current
directory whose contents
-mention ‘<samp><span class="samp">main</span></samp>’.
-
- <li>How do I search directories recursively?
-
- <pre class="example"> grep -r 'hello' /home/gigi
-</pre>
- <p class="noindent">searches for ‘<samp><span
class="samp">hello</span></samp>’ in all files
-under the <samp><span class="file">/home/gigi</span></samp> directory.
+<p>searches for ‘<samp>hello</samp>’ in all files
+under the <samp>/home/gigi</samp> directory.
For more control over which files are searched,
-use <samp><span class="command">find</span></samp>, <samp><span
class="command">grep</span></samp>, and <samp><span
class="command">xargs</span></samp>.
+use <code>find</code>, <code>grep</code>, and <code>xargs</code>.
For example, the following command searches only C files:
-
- <pre class="example"> find /home/gigi -name '*.c' -print0 |
xargs -0r grep -H 'hello'
-</pre>
- <p>This differs from the command:
-
- <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>’.
-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
-</pre>
- <li>What if a pattern has a leading ‘<samp><span
class="samp">-</span></samp>’?
-
- <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="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
+</p>
+<div class="example">
+<pre class="example">find /home/gigi -name '*.c' -print0 | xargs -0r grep -H
'hello'
+</pre></div>
+
+<p>This differs from the command:
+</p>
+<div class="example">
+<pre class="example">grep -H 'hello' *.c
+</pre></div>
+
+<p>which merely looks for ‘<samp>hello</samp>’ in all files in the
current
+directory whose names end in ‘<samp>.c</samp>’.
+The ‘<samp>find ...</samp>’ command line above is more similar to
the command:
+</p>
+<div class="example">
+<pre class="example">grep -rH --include='*.c' 'hello' /home/gigi
+</pre></div>
+
+</li><li> What if a pattern has a leading ‘<samp>-</samp>’?
+
+<div class="example">
+<pre class="example">grep -e '--cut here--' *
+</pre></div>
+
+<p>searches for all lines matching ‘<samp>--cut here--</samp>’.
+Without <samp>-e</samp>,
+<code>grep</code> would attempt to parse ‘<samp>--cut
here--</samp>’ as a list of
options.
+</p>
+</li><li> Suppose I want to search for a whole word, not a part of a word?
- <li>Suppose I want to search for a whole word, not a part of a word?
-
- <pre class="example"> grep -w 'hello' *
-</pre>
- <p class="noindent">searches only for instances of ‘<samp><span
class="samp">hello</span></samp>’ that are entire words;
-it does not match ‘<samp><span
class="samp">Othello</span></samp>’.
-For more control, use ‘<samp><span
class="samp">\<</span></samp>’ and
-‘<samp><span class="samp">\></span></samp>’ to match the start
and end of words.
+<div class="example">
+<pre class="example">grep -w 'hello' *
+</pre></div>
+
+<p>searches only for instances of ‘<samp>hello</samp>’ that are
entire words;
+it does not match ‘<samp>Othello</samp>’.
+For more control, use ‘<samp>\<</samp>’ and
+‘<samp>\></samp>’ to match the start and end of words.
For example:
-
- <pre class="example"> grep 'hello\>' *
-</pre>
- <p class="noindent">searches only for words ending in ‘<samp><span
class="samp">hello</span></samp>’, so it matches the word
-‘<samp><span class="samp">Othello</span></samp>’.
-
- <li>How do I output context around the matching lines?
-
- <pre class="example"> grep -C 2 'hello' *
-</pre>
- <p class="noindent">prints two lines of context around each matching line.
-
- <li>How do I force <samp><span class="command">grep</span></samp> to
print the name of the file?
-
- <p>Append <samp><span class="file">/dev/null</span></samp>:
-
- <pre class="example"> grep 'eli' /etc/passwd /dev/null
-</pre>
- <p>gets you:
-
- <pre class="example"> /etc/passwd:eli:x:2098:1000:Eli
Smith:/home/eli:/bin/bash
-</pre>
- <p>Alternatively, use <samp><span class="option">-H</span></samp>, which
is a GNU extension:
-
- <pre class="example"> grep -H 'eli' /etc/passwd
-</pre>
- <li>Why do people use strange regular expressions on <samp><span
class="command">ps</span></samp> output?
-
- <pre class="example"> ps -ef | grep '[c]ron'
-</pre>
- <p>If the pattern had been written without the square brackets, it would
-have matched not only the <samp><span class="command">ps</span></samp> output
line for <samp><span class="command">cron</span></samp>,
-but also the <samp><span class="command">ps</span></samp> output line for
<samp><span class="command">grep</span></samp>.
+</p>
+<div class="example">
+<pre class="example">grep 'hello\>' *
+</pre></div>
+
+<p>searches only for words ending in ‘<samp>hello</samp>’, so it
matches the word
+‘<samp>Othello</samp>’.
+</p>
+</li><li> How do I output context around the matching lines?
+
+<div class="example">
+<pre class="example">grep -C 2 'hello' *
+</pre></div>
+
+<p>prints two lines of context around each matching line.
+</p>
+</li><li> How do I force <code>grep</code> to print the name of the file?
+
+<p>Append <samp>/dev/null</samp>:
+</p>
+<div class="example">
+<pre class="example">grep 'eli' /etc/passwd /dev/null
+</pre></div>
+
+<p>gets you:
+</p>
+<div class="example">
+<pre class="example">/etc/passwd:eli:x:2098:1000:Eli Smith:/home/eli:/bin/bash
+</pre></div>
+
+<p>Alternatively, use <samp>-H</samp>, which is a GNU extension:
+</p>
+<div class="example">
+<pre class="example">grep -H 'eli' /etc/passwd
+</pre></div>
+
+</li><li> Why do people use strange regular expressions on <code>ps</code>
output?
+
+<div class="example">
+<pre class="example">ps -ef | grep '[c]ron'
+</pre></div>
+
+<p>If the pattern had been written without the square brackets, it would
+have matched not only the <code>ps</code> output line for <code>cron</code>,
+but also the <code>ps</code> output line for <code>grep</code>.
Note that on some platforms,
-<samp><span class="command">ps</span></samp> limits the output to the width of
the screen;
-<samp><span class="command">grep</span></samp> does not have any limit on the
length of a line
+<code>ps</code> limits the output to the width of the screen;
+<code>grep</code> does not have any limit on the length of a line
except the available memory.
+</p>
+</li><li> Why does <code>grep</code> report “Binary file matches”?
- <li>Why does <samp><span class="command">grep</span></samp> report
“Binary file matches”?
-
- <p>If <samp><span class="command">grep</span></samp> listed all matching
“lines” from a binary file, it
+<p>If <code>grep</code> 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 GNU <samp><span class="command">grep</span></samp> suppresses output from
+So GNU <code>grep</code> suppresses output from
files that appear to be binary files.
-To force GNU <samp><span class="command">grep</span></samp>
+To force GNU <code>grep</code>
to output lines even from files that appear to be binary, use the
-<samp><span class="option">-a</span></samp> or ‘<samp><span
class="samp">--binary-files=text</span></samp>’ option.
+<samp>-a</samp> or ‘<samp>--binary-files=text</samp>’ option.
To eliminate the
-“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?
+“Binary file matches” messages, use the <samp>-I</samp> or
+‘<samp>--binary-files=without-match</samp>’ option.
+</p>
+</li><li> Why doesn’t ‘<samp>grep -lv</samp>’ print
non-matching file names?
- <p>‘<samp><span class="samp">grep -lv</span></samp>’ lists
the names of all files containing one or more
+<p>‘<samp>grep -lv</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="option">-L</span></samp> or
<samp><span class="option">--files-without-match</span></samp>
+matching lines, use the <samp>-L</samp> or <samp>--files-without-match</samp>
option.
+</p>
+</li><li> I can do “OR” with ‘<samp>|</samp>’, but
what about “AND”?
- <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?
+<div class="example">
+<pre class="example">grep 'paul' /etc/motd | grep 'franc,ois'
+</pre></div>
+
+<p>finds all lines that contain both ‘<samp>paul</samp>’ and
‘<samp>franc,ois</samp>’.
+</p>
+</li><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
+<p>The <code>grep</code> 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.
+empty pattern causes <code>grep</code> to find a match on each line. It
+is not the only such pattern: ‘<samp>^</samp>’,
‘<samp>$</samp>’, ‘<samp>.*</samp>’, and many
+other patterns cause <code>grep</code> to match every line.
+</p>
+<p>To match empty lines, use the pattern ‘<samp>^$</samp>’. To
match blank
+lines, use the pattern ‘<samp>^[[:blank:]]*$</samp>’. To match no
lines at
+all, use the command ‘<samp>grep -f /dev/null</samp>’.
+</p>
+</li><li> How can I search in both standard input and in files?
+
+<p>Use the special file name ‘<samp>-</samp>’:
+</p>
+<div class="example">
+<pre class="example">cat /etc/passwd | grep 'alain' - /etc/motd
+</pre></div>
- <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><li> <a name="index-palindromes"></a>
+How to express palindromes in a regular expression?
- <li>How can I search in both standard input and in files?
-
- <p>Use the special file name ‘<samp><span
class="samp">-</span></samp>’:
-
- <pre class="example"> cat /etc/passwd | grep 'alain' - /etc/motd
-</pre>
- <li><a name="index-palindromes-258"></a>How to express palindromes in a
regular expression?
-
- <p>It can be done by using back-references;
+<p>It can be done by using back-references;
for example,
a palindrome of 4 characters can be written with a BRE:
-
- <pre class="example"> grep -w -e '\(.\)\(.\).\2\1' file
-</pre>
- <p>It matches the word “radar” or “civic.”
-
- <p>Guglielmo Bondioni proposed a single RE
+</p>
+<div class="example">
+<pre class="example">grep -w -e '\(.\)\(.\).\2\1' file
+</pre></div>
+
+<p>It matches the word “radar” or “civic.”
+</p>
+<p>Guglielmo Bondioni proposed a single RE
that finds all palindromes up to 19 characters long
-using 9 subexpressions<!-- /@w --> and 9 back-references<!-- /@w -->:
+using 9 subexpressions<!-- /@w --> and 9 <span
class="nolinebreak">back-references</span><!-- /@w -->:
+</p>
+<div class="smallexample">
+<pre class="smallexample">grep -E -e
'^(.?)(.?)(.?)(.?)(.?)(.?)(.?)(.?)(.?).?\9\8\7\6\5\4\3\2\1$' file
+</pre></div>
+
+<p>Note this is done by using GNU ERE extensions;
+it might not be portable to other implementations of <code>grep</code>.
+</p>
+</li><li> Why is this back-reference failing?
+
+<div class="example">
+<pre class="example">echo 'ba' | grep -E '(a)\1|b\1'
+</pre></div>
- <pre class="smallexample"> grep -E -e
'^(.?)(.?)(.?)(.?)(.?)(.?)(.?)(.?)(.?).?\9\8\7\6\5\4\3\2\1$' file
-</pre>
- <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?
-
- <pre class="example"> echo 'ba' | grep -E '(a)\1|b\1'
-</pre>
- <p>This gives no output, because the first alternate ‘<samp><span
class="samp">(a)\1</span></samp>’ does not match,
-as there is no ‘<samp><span class="samp">aa</span></samp>’ in the
input, so the ‘<samp><span class="samp">\1</span></samp>’ in the
second alternate
+<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
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?
- <li>How can I match across lines?
-
- <p>Standard grep cannot do this, as it is fundamentally line-based.
+<p>Standard grep cannot do this, as it is fundamentally line-based.
Therefore, merely using the <code>[:space:]</code> character class does not
match newlines in the way you might expect.
-
- <p>With the GNU <samp><span class="command">grep</span></samp> option
<samp><span class="option">-z</span></samp> (<samp><span
class="option">--null-data</span></samp>), each
+</p>
+<p>With the GNU <code>grep</code> option <samp>-z</samp>
(<samp>--null-data</samp>), each
input “line” is terminated by a null byte; see <a
href="Other-Options.html#Other-Options">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><span class="option">-q</span></samp>,
e.g.:
-
- <pre class="example"> printf 'foo\nbar\n' | grep -z -q
'foo[[:space:]]\+bar'
-</pre>
- <p>If this does not suffice, you can transform the input
-before giving it to <samp><span class="command">grep</span></samp>, or turn to
<samp><span class="command">awk</span></samp>,
-<samp><span class="command">sed</span></samp>, <samp><span
class="command">perl</span></samp>, or many other utilities that are
+output-suppressing options like <samp>-q</samp>, e.g.:
+</p>
+<div class="example">
+<pre class="example">printf 'foo\nbar\n' | grep -z -q 'foo[[:space:]]\+bar'
+</pre></div>
+
+<p>If this does not suffice, you can transform the input
+before giving it to <code>grep</code>, or turn to <code>awk</code>,
+<code>sed</code>, <code>perl</code>, or many other utilities that are
designed to operate across lines.
+</p>
+</li><li> What do <code>grep</code>, <code>fgrep</code>, and
<code>egrep</code> stand for?
- <li>What do <samp><span class="command">grep</span></samp>, <samp><span
class="command">fgrep</span></samp>, and <samp><span
class="command">egrep</span></samp> stand for?
-
- <p>The name <samp><span class="command">grep</span></samp> comes from the
way line editing was done on Unix.
+<p>The name <code>grep</code> comes from the way line editing was done on Unix.
For example,
-<samp><span class="command">ed</span></samp> uses the following syntax
+<code>ed</code> uses the following syntax
to print a list of matching lines on the screen:
+</p>
+<div class="example">
+<pre class="example">global/regular expression/print
+g/re/p
+</pre></div>
+
+<p><code>fgrep</code> stands for Fixed <code>grep</code>;
+<code>egrep</code> stands for Extended <code>grep</code>.
+</p>
+</li></ol>
- <pre class="example"> global/regular expression/print
- g/re/p
-</pre>
- <p><samp><span class="command">fgrep</span></samp> stands for Fixed
<samp><span class="command">grep</span></samp>;
-<samp><span class="command">egrep</span></samp> stands for Extended
<samp><span class="command">grep</span></samp>.
- </ol>
+<hr>
+<div class="header">
+<p>
+Next: <a href="Reporting-Bugs.html#Reporting-Bugs" accesskey="n"
rel="next">Reporting Bugs</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>
+</div>
+
- </body></html>
+</body>
+</html>
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- Changes to grep/manual/html_node/Usage.html,v,
Jim Meyering <=