[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: |
Wed, 22 Mar 2023 22:55:26 -0400 (EDT) |
CVSROOT: /webcvs/grep
Module name: grep
Changes by: Jim Meyering <meyering> 23/03/22 22:55:22
Index: html_node/Usage.html
===================================================================
RCS file: /webcvs/grep/grep/manual/html_node/Usage.html,v
retrieving revision 1.33
retrieving revision 1.34
diff -u -b -r1.33 -r1.34
--- html_node/Usage.html 3 Sep 2022 19:33:14 -0000 1.33
+++ html_node/Usage.html 23 Mar 2023 02:55:21 -0000 1.34
@@ -1,11 +1,11 @@
-<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
+<!DOCTYPE html>
<html>
-<!-- Created by GNU Texinfo 6.8, https://www.gnu.org/software/texinfo/ -->
+<!-- Created by GNU Texinfo 7.0dev, 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-2022 Free Software Foundation,
+Copyright © 1999-2002, 2005, 2008-2023 Free Software Foundation,
Inc.
Permission is granted to copy, distribute and/or modify this document
@@ -14,10 +14,10 @@
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". -->
-<title>Usage (GNU Grep 3.8)</title>
+<title>Usage (GNU Grep 3.10)</title>
-<meta name="description" content="Usage (GNU Grep 3.8)">
-<meta name="keywords" content="Usage (GNU Grep 3.8)">
+<meta name="description" content="Usage (GNU Grep 3.10)">
+<meta name="keywords" content="Usage (GNU Grep 3.10)">
<meta name="resource-type" content="document">
<meta name="distribution" content="global">
<meta name="Generator" content="makeinfo">
@@ -31,21 +31,9 @@
<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}
-div.display {margin-left: 3.2em}
+a.copiable-link {visibility: hidden; text-decoration: none; line-height: 0em}
div.example {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}
-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}
+span:hover a.copiable-link {visibility: visible}
-->
</style>
<link rel="stylesheet" type="text/css"
href="https://www.gnu.org/software/gnulib/manual.css">
@@ -54,317 +42,317 @@
</head>
<body lang="en">
-<div class="chapter" id="Usage">
-<div class="header">
+<div class="chapter-level-extent" id="Usage">
+<div class="nav-panel">
<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>
-<span id="Usage-1"></span><h2 class="chapter">4 Usage</h2>
+<h2 class="chapter" id="Usage-1"><span>4 Usage<a class="copiable-link"
href="#Usage-1"> ¶</a></span></h2>
-<span id="index-usage_002c-examples"></span>
-<p>Here is an example command that invokes GNU <code>grep</code>:
+<a class="index-entry-id" id="index-usage_002c-examples"></a>
+<p>Here is an example command that invokes GNU <code
class="command">grep</code>:
</p>
<div class="example">
-<pre class="example">grep -i 'hello.*world' menu.h main.c
+<pre class="example-preformatted">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</a>.
-The <samp>-i</samp> option causes <code>grep</code>
-to ignore case, causing it to match the line ‘<samp>Hello,
world!</samp>’, which
+<p>This lists all lines in the files <samp class="file">menu.h</samp> and
<samp class="file">main.c</samp> that
+contain the string ‘<samp class="samp">hello</samp>’ followed by
the string ‘<samp class="samp">world</samp>’;
+this is because ‘<samp class="samp">.*</samp>’ matches zero or
more characters within a line.
+See <a class="xref" href="Regular-Expressions.html">Regular Expressions</a>.
+The <samp class="option">-i</samp> option causes <code
class="command">grep</code>
+to ignore case, causing it to match the line ‘<samp class="samp">Hello,
world!</samp>’, which
it would not otherwise match.
</p>
<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>’,
+containing ‘<samp class="samp">f</samp>’ and ending in
‘<samp class="samp">.c</samp>’,
within all files in the current directory whose names
-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
+start with non-‘<samp class="samp">.</samp>’, contain ‘<samp
class="samp">g</samp>’, and end in ‘<samp
class="samp">.h</samp>’.
+The <samp class="option">-n</samp> option outputs line numbers, the <samp
class="option">--</samp> argument
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>’.
+<code class="code">*g*.h</code> expands to a file name that starts with
‘<samp class="samp">-</samp>’,
+and the empty file <samp class="file">/dev/null</samp> causes file names to be
output
+even if only one file name happens to be of the form ‘<samp
class="samp">*g*.h</samp>’.
</p>
<div class="example">
-<pre class="example">grep -n -- 'f.*\.c$' *g*.h /dev/null
+<pre class="example-preformatted">grep -n -- 'f.*\.c$' *g*.h /dev/null
</pre></div>
<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 <code>grep</code></a>, for more
details about
-how to invoke <code>grep</code>.
+<p>See <a class="xref" href="Invoking.html">Invoking <code
class="command">grep</code></a>, for more details about
+how to invoke <code class="command">grep</code>.
</p>
-<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.
+<a class="index-entry-id" id="index-using-grep_002c-Q_0026A"></a>
+<a class="index-entry-id" id="index-FAQ-about-grep-usage"></a>
+<p>Here are some common questions and answers about <code
class="command">grep</code> usage.
</p>
-<ol>
+<ol class="enumerate">
<li> How can I list just the names of matching files?
<div class="example">
-<pre class="example">grep -l 'main' test-*.c
+<pre class="example-preformatted">grep -l 'main' test-*.c
</pre></div>
-<p>lists names of ‘<samp>test-*.c</samp>’ files in the current
directory whose contents
-mention ‘<samp>main</samp>’.
+<p>lists names of ‘<samp class="samp">test-*.c</samp>’ files in
the current directory whose contents
+mention ‘<samp class="samp">main</samp>’.
</p>
</li><li> How do I search directories recursively?
<div class="example">
-<pre class="example">grep -r 'hello' /home/gigi
+<pre class="example-preformatted">grep -r 'hello' /home/gigi
</pre></div>
-<p>searches for ‘<samp>hello</samp>’ in all files
-under the <samp>/home/gigi</samp> directory.
+<p>searches for ‘<samp class="samp">hello</samp>’ in all files
+under the <samp class="file">/home/gigi</samp> directory.
For more control over which files are searched,
-use <code>find</code> and <code>grep</code>.
+use <code class="command">find</code> and <code class="command">grep</code>.
For example, the following command searches only C files:
</p>
<div class="example">
-<pre class="example">find /home/gigi -name '*.c' ! -type d \
+<pre class="example-preformatted">find /home/gigi -name '*.c' ! -type d \
-exec grep -H 'hello' '{}' +
</pre></div>
<p>This differs from the command:
</p>
<div class="example">
-<pre class="example">grep -H 'hello' /home/gigi/*.c
+<pre class="example-preformatted">grep -H 'hello' /home/gigi/*.c
</pre></div>
-<p>which merely looks for ‘<samp>hello</samp>’ in non-hidden C
files in
-<samp>/home/gigi</samp> whose names end in ‘<samp>.c</samp>’.
-The <code>find</code> command line above is more similar to the command:
+<p>which merely looks for ‘<samp class="samp">hello</samp>’ in
non-hidden C files in
+<samp class="file">/home/gigi</samp> whose names end in ‘<samp
class="samp">.c</samp>’.
+The <code class="command">find</code> command line above is more similar to
the command:
</p>
<div class="example">
-<pre class="example">grep -r --include='*.c' 'hello' /home/gigi
+<pre class="example-preformatted">grep -r --include='*.c' 'hello' /home/gigi
</pre></div>
-</li><li> What if a pattern or file has a leading ‘<samp>-</samp>’?
+</li><li> What if a pattern or file has a leading ‘<samp
class="samp">-</samp>’?
For example:
<div class="example">
-<pre class="example">grep "$pattern" *
+<pre class="example-preformatted">grep "$pattern" *
</pre></div>
-<p>can behave unexpectedly if the value of ‘<samp>pattern</samp>’
begins with ‘<samp>-</samp>’,
-or if the ‘<samp>*</samp>’ expands to a file name with leading
‘<samp>-</samp>’.
-To avoid the problem, you can use <samp>-e</samp> for patterns and leading
-‘<samp>./</samp>’ for files:
+<p>can behave unexpectedly if the value of ‘<samp
class="samp">pattern</samp>’ begins with ‘<samp
class="samp">-</samp>’,
+or if the ‘<samp class="samp">*</samp>’ expands to a file name
with leading ‘<samp class="samp">-</samp>’.
+To avoid the problem, you can use <samp class="option">-e</samp> for patterns
and leading
+‘<samp class="samp">./</samp>’ for files:
</p>
<div class="example">
-<pre class="example">grep -e "$pattern" ./*
+<pre class="example-preformatted">grep -e "$pattern" ./*
</pre></div>
<p>searches for all lines matching the pattern in all the working
-directory’s files whose names do not begin with
‘<samp>.</samp>’.
-Without the <samp>-e</samp>, <code>grep</code> might treat the pattern as an
-option if it begins with ‘<samp>-</samp>’. Without the
‘<samp>./</samp>’, there might
-be similar problems with file names beginning with
‘<samp>-</samp>’.
+directory’s files whose names do not begin with ‘<samp
class="samp">.</samp>’.
+Without the <samp class="option">-e</samp>, <code class="command">grep</code>
might treat the pattern as an
+option if it begins with ‘<samp class="samp">-</samp>’. Without
the ‘<samp class="samp">./</samp>’, there might
+be similar problems with file names beginning with ‘<samp
class="samp">-</samp>’.
</p>
-<p>Alternatively, you can use ‘<samp>--</samp>’ before the pattern
and file names:
+<p>Alternatively, you can use ‘<samp class="samp">--</samp>’
before the pattern and file names:
</p>
<div class="example">
-<pre class="example">grep -- "$pattern" *
+<pre class="example-preformatted">grep -- "$pattern" *
</pre></div>
-<p>This also fixes the problem, except that if there is a file named
‘<samp>-</samp>’,
-<code>grep</code> misinterprets the ‘<samp>-</samp>’ as standard
input.
+<p>This also fixes the problem, except that if there is a file named
‘<samp class="samp">-</samp>’,
+<code class="command">grep</code> misinterprets the ‘<samp
class="samp">-</samp>’ as standard input.
</p>
</li><li> Suppose I want to search for a whole word, not a part of a word?
<div class="example">
-<pre class="example">grep -w 'hello' test*.log
+<pre class="example-preformatted">grep -w 'hello' test*.log
</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.
+<p>searches only for instances of ‘<samp
class="samp">hello</samp>’ that are entire words;
+it does not match ‘<samp class="samp">Othello</samp>’.
+For more control, use ‘<samp class="samp">\<</samp>’ and
+‘<samp class="samp">\></samp>’ to match the start and end of
words.
For example:
</p>
<div class="example">
-<pre class="example">grep 'hello\>' test*.log
+<pre class="example-preformatted">grep 'hello\>' test*.log
</pre></div>
-<p>searches only for words ending in ‘<samp>hello</samp>’, so it
matches the word
-‘<samp>Othello</samp>’.
+<p>searches only for words ending in ‘<samp
class="samp">hello</samp>’, so it matches the word
+‘<samp class="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' test*.log
+<pre class="example-preformatted">grep -C 2 'hello' test*.log
</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?
+</li><li> How do I force <code class="command">grep</code> to print the name
of the file?
-<p>Append <samp>/dev/null</samp>:
+<p>Append <samp class="file">/dev/null</samp>:
</p>
<div class="example">
-<pre class="example">grep 'eli' /etc/passwd /dev/null
+<pre class="example-preformatted">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 class="example-preformatted">/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>Alternatively, use <samp class="option">-H</samp>, which is a GNU extension:
</p>
<div class="example">
-<pre class="example">grep -H 'eli' /etc/passwd
+<pre class="example-preformatted">grep -H 'eli' /etc/passwd
</pre></div>
-</li><li> Why do people use strange regular expressions on <code>ps</code>
output?
+</li><li> Why do people use strange regular expressions on <code
class="command">ps</code> output?
<div class="example">
-<pre class="example">ps -ef | grep '[c]ron'
+<pre class="example-preformatted">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>.
+have matched not only the <code class="command">ps</code> output line for
<code class="command">cron</code>,
+but also the <code class="command">ps</code> output line for <code
class="command">grep</code>.
Note that on some platforms,
-<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
+<code class="command">ps</code> limits the output to the width of the screen;
+<code class="command">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><li> Why does <code class="command">grep</code> report “Binary file
matches”?
-<p>If <code>grep</code> listed all matching “lines” from a binary
file, it
+<p>If <code class="command">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 <code>grep</code> suppresses output from
+So GNU <code class="command">grep</code> suppresses output from
files that appear to be binary files.
-To force GNU <code>grep</code>
+To force GNU <code class="command">grep</code>
to output lines even from files that appear to be binary, use the
-<samp>-a</samp> or ‘<samp>--binary-files=text</samp>’ option.
+<samp class="option">-a</samp> or ‘<samp
class="samp">--binary-files=text</samp>’ option.
To eliminate the
-“Binary file matches” messages, use the <samp>-I</samp> or
-‘<samp>--binary-files=without-match</samp>’ option.
+“Binary file matches” messages, use the <samp
class="option">-I</samp> or
+‘<samp class="samp">--binary-files=without-match</samp>’ option.
</p>
-</li><li> Why doesn’t ‘<samp>grep -lv</samp>’ print
non-matching file names?
+</li><li> Why doesn’t ‘<samp class="samp">grep -lv</samp>’
print non-matching file names?
-<p>‘<samp>grep -lv</samp>’ lists the names of all files containing
one or more
+<p>‘<samp class="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>-L</samp> or <samp>--files-without-match</samp>
+matching lines, use the <samp class="option">-L</samp> or <samp
class="option">--files-without-match</samp>
option.
</p>
-</li><li> I can do “OR” with ‘<samp>|</samp>’, but
what about “AND”?
+</li><li> I can do “OR” with ‘<samp
class="samp">|</samp>’, but what about “AND”?
<div class="example">
-<pre class="example">grep 'paul' /etc/motd | grep 'franc,ois'
+<pre class="example-preformatted">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>finds all lines that contain both ‘<samp
class="samp">paul</samp>’ and ‘<samp
class="samp">franc,ois</samp>’.
</p>
</li><li> Why does the empty pattern match every input line?
-<p>The <code>grep</code> command searches for lines that contain strings
+<p>The <code class="command">grep</code> command searches for lines that
contain strings
that match a pattern. Every line contains the empty string, so an
-empty pattern causes <code>grep</code> to find a match on each line. It
-is not the only such pattern: ‘<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 an extended regular expression like ‘<samp>a^</samp>’ or
‘<samp>$a</samp>’.
+empty pattern causes <code class="command">grep</code> to find a match on each
line. It
+is not the only such pattern: ‘<samp class="samp">^</samp>’,
‘<samp class="samp">$</samp>’, and many
+other patterns cause <code class="command">grep</code> to match every line.
+</p>
+<p>To match empty lines, use the pattern ‘<samp
class="samp">^$</samp>’. To match blank
+lines, use the pattern ‘<samp class="samp">^[[:blank:]]*$</samp>’.
To match no lines at
+all, use an extended regular expression like ‘<samp
class="samp">a^</samp>’ or ‘<samp class="samp">$a</samp>’.
To match every line, a portable script should use a pattern like
-‘<samp>^</samp>’ instead of the empty pattern, as POSIX does not
specify the
+‘<samp class="samp">^</samp>’ instead of the empty pattern, as
POSIX does not specify the
behavior of the empty pattern.
</p>
</li><li> How can I search in both standard input and in files?
-<p>Use the special file name ‘<samp>-</samp>’:
+<p>Use the special file name ‘<samp class="samp">-</samp>’:
</p>
<div class="example">
-<pre class="example">cat /etc/passwd | grep 'alain' - /etc/motd
+<pre class="example-preformatted">cat /etc/passwd | grep 'alain' - /etc/motd
</pre></div>
-</li><li> Why can’t I combine the shell’s ‘<samp>set
-e</samp>’ with <code>grep</code>?
+</li><li> Why can’t I combine the shell’s ‘<samp
class="samp">set -e</samp>’ with <code class="command">grep</code>?
-<p>The <code>grep</code> command follows the convention of programs like
-<code>cmp</code> and <code>diff</code> where an exit status of 1 is not an
-error. The shell command ‘<samp>set -e</samp>’ causes the shell
to exit if
+<p>The <code class="command">grep</code> command follows the convention of
programs like
+<code class="command">cmp</code> and <code class="command">diff</code> where
an exit status of 1 is not an
+error. The shell command ‘<samp class="samp">set -e</samp>’
causes the shell to exit if
any subcommand exits with nonzero status, and this will cause the
-shell to exit merely because <code>grep</code> selected no lines,
+shell to exit merely because <code class="command">grep</code> selected no
lines,
which is ordinarily not what you want.
</p>
-<p>There is a related problem with Bash’s <code>set -e -o
pipefail</code>.
-Since <code>grep</code> does not always read all its input, a command
-outputting to a pipe read by <code>grep</code> can fail when
-<code>grep</code> exits before reading all its input, and the command’s
+<p>There is a related problem with Bash’s <code class="command">set -e
-o pipefail</code>.
+Since <code class="command">grep</code> does not always read all its input, a
command
+outputting to a pipe read by <code class="command">grep</code> can fail when
+<code class="command">grep</code> exits before reading all its input, and the
command’s
failure can cause Bash to exit.
</p>
</li><li> Why is this back-reference failing?
<div class="example">
-<pre class="example">echo 'ba' | grep -E '(a)\1|b\1'
+<pre class="example-preformatted">echo 'ba' | grep -E '(a)\1|b\1'
</pre></div>
-<p>This outputs an error message, because the second
‘<samp>\1</samp>’
+<p>This outputs an error message, because the second ‘<samp
class="samp">\1</samp>’
has nothing to refer back to, meaning it will never match anything.
</p>
</li><li> How can I match across lines?
<p>Standard grep cannot do this, as it is fundamentally line-based.
-Therefore, merely using the <code>[:space:]</code> character class does not
+Therefore, merely using the <code class="code">[:space:]</code> character
class does not
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</a>. Thus,
+<p>With the GNU <code class="command">grep</code> option <samp
class="option">-z</samp> (<samp class="option">--null-data</samp>), each
+input and output “line” is null-terminated; see <a class="pxref"
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.:
+output-suppressing options like <samp class="option">-q</samp>, e.g.:
</p>
<div class="example">
-<pre class="example">printf 'foo\nbar\n' | grep -z -q 'foo[[:space:]]\+bar'
+<pre class="example-preformatted">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
+before giving it to <code class="command">grep</code>, or turn to <code
class="command">awk</code>,
+<code class="command">sed</code>, <code class="command">perl</code>, or many
other utilities that are
designed to operate across lines.
</p>
-</li><li> What do <code>grep</code>, <samp>-E</samp>, and <samp>-F</samp>
stand for?
+</li><li> What do <code class="command">grep</code>, <samp
class="option">-E</samp>, and <samp class="option">-F</samp> stand for?
-<p>The name <code>grep</code> comes from the way line editing was done on Unix.
+<p>The name <code class="command">grep</code> comes from the way line editing
was done on Unix.
For example,
-<code>ed</code> uses the following syntax
+<code class="command">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
+<pre class="example-preformatted">global/regular expression/print
g/re/p
</pre></div>
-<p>The <samp>-E</samp> option stands for Extended <code>grep</code>.
-The <samp>-F</samp> option stands for Fixed <code>grep</code>;
+<p>The <samp class="option">-E</samp> option stands for Extended <code
class="command">grep</code>.
+The <samp class="option">-F</samp> option stands for Fixed <code
class="command">grep</code>;
</p>
-</li><li> What happened to <code>egrep</code> and <code>fgrep</code>?
+</li><li> What happened to <code class="command">egrep</code> and <code
class="command">fgrep</code>?
-<p>7th Edition Unix had commands <code>egrep</code> and <code>fgrep</code>
-that were the counterparts of the modern ‘<samp>grep -E</samp>’
and ‘<samp>grep -F</samp>’.
-Although breaking up <code>grep</code> into three programs was perhaps
-useful on the small computers of the 1970s, <code>egrep</code> and
-<code>fgrep</code> were not standardized by POSIX and are no longer needed.
-In the current GNU implementation, <code>egrep</code> and <code>fgrep</code>
-issue a warning and then act like their modern counterparts;
+<p>7th Edition Unix had commands <code class="command">egrep</code> and <code
class="command">fgrep</code>
+that were the counterparts of the modern ‘<samp class="samp">grep
-E</samp>’ and ‘<samp class="samp">grep -F</samp>’.
+Although breaking up <code class="command">grep</code> into three programs was
perhaps
+useful on the small computers of the 1970s, <code class="command">egrep</code>
and
+<code class="command">fgrep</code> were deemed obsolescent by POSIX in 1992,
+removed from POSIX in 2001, deprecated by GNU Grep 2.5.3 in 2007,
+and changed to issue obsolescence warnings by GNU Grep 3.8 in 2022;
eventually, they are planned to be removed entirely.
</p>
<p>If you prefer the old names, you can use use your own substitutes,
-such as a shell script named <code>egrep</code> with the following
+such as a shell script named <code class="command">egrep</code> with the
following
contents:
</p>
<div class="example">
-<pre class="example">#!/bin/sh
+<pre class="example-preformatted">#!/bin/sh
exec grep -E "$@"
</pre></div>
@@ -373,7 +361,7 @@
</div>
<hr>
-<div class="header">
+<div class="nav-panel">
<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>
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- Changes to grep/manual/html_node/Usage.html,v,
Jim Meyering <=