summaryrefslogtreecommitdiff
path: root/doc
diff options
context:
space:
mode:
authorJulian Foad <julianfoad@btopenworld.com>2005-11-08 19:45:05 +0000
committerJulian Foad <julianfoad@btopenworld.com>2005-11-08 19:45:05 +0000
commitbd2e5d765507ebe29a4da92aa327ebb77cb60eb6 (patch)
tree0c314658494768d2b6bce5403ffcbf6d426bb535 /doc
parentb9b81bd2fa4373ec4d7f3aa6f27ee14fe85d1930 (diff)
downloadgrep-bd2e5d765507ebe29a4da92aa327ebb77cb60eb6.tar.gz
Rewrite a poorly written usage example.
* doc/grep.texi: Rewrite a poorly written usage example about back-references, and tweak another. New text by Benno Schulenberg.
Diffstat (limited to 'doc')
-rw-r--r--doc/grep.texi20
1 files changed, 11 insertions, 9 deletions
diff --git a/doc/grep.texi b/doc/grep.texi
index dd751f38..dcff8614 100644
--- a/doc/grep.texi
+++ b/doc/grep.texi
@@ -1251,22 +1251,24 @@ Note this is done by using GNU ERE extensions, it might not be portable on
other greps.
@item
-Why are my expressions whith the vertical bar fail?
+Why is this back-reference failing?
@example
-/bin/echo "ba" | egrep '(a)\1|(b)\1'
+echo 'ba' | egrep '(a)\1|b\1'
@end example
-The first alternate branch fails then the first group was not in the match
-this will make the second alternate branch fails. For example, "aaba" will
-match, the first group participate in the match and can be reuse in the
-second branch.
+This gives no output, because the first alternate @samp{(a)\1} does not match,
+as there is no @samp{aa} in the input, so the @samp{\1} 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.)
@item
-What do @command{grep, fgrep, egrep} stand for ?
+What do @command{grep, fgrep, egrep} stand for?
-grep comes from the way line editing was done on Unix. For example,
-@command{ed} uses this syntax to print a list of matching lines on the screen.
+The name @command{grep} comes from the way line editing was done on Unix. For
+example, @command{ed} uses the following syntax to print a list of matching
+lines on the screen:
@example
global/regular expression/print