grep-commit
[Top][All Lists]
Advanced

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

grep branch, master, updated. v2.6.3-76-g28ec5d3


From: Jim Meyering
Subject: grep branch, master, updated. v2.6.3-76-g28ec5d3
Date: Sat, 29 May 2010 08:33:13 +0000

This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "grep".

The branch, master has been updated
       via  28ec5d35539fd63d8914517e59de8c6f5082dab9 (commit)
      from  6fa0d1364bad16e09839a24a78f27a0fe0cf6b67 (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.

- Log -----------------------------------------------------------------
http://git.savannah.gnu.org/cgit/grep.git/commit/?id=28ec5d35539fd63d8914517e59de8c6f5082dab9


commit 28ec5d35539fd63d8914517e59de8c6f5082dab9
Author: Karl Berry <address@hidden>
Date:   Sat May 29 10:29:59 2010 +0200

    doc: discuss matches that span two or more lines
    
    * doc/grep.texi (Usage): Discuss matching across lines.
    (Character Classes and Bracket Expressions) <[:space:]>: refer to it.

diff --git a/doc/grep.texi b/doc/grep.texi
index 87480de..9ee4bc4 100644
--- a/doc/grep.texi
+++ b/doc/grep.texi
@@ -1246,6 +1246,7 @@ Punctuation characters:
 @cindex whitespace characters
 Space characters:
 tab, newline, vertical tab, form feed, carriage return, and space.
address@hidden, for more discussion of matching newlines.
 
 @item [:upper:]
 @opindex upper @r{character class}
@@ -1620,7 +1621,35 @@ 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.)
+if the first alternate has matched---making the second one superfluous.)
+
address@hidden
+How can I match across lines?
+
+Standard grep cannot do this, as it is fundamentally line-based.
+Therefore, merely using the @code{[:space:]} character class does not
+match newlines in the way you might expect.  However, if your grep is
+compiled with Perl patterns enabled, the Perl @samp{s}
+modifier (which makes @code{.} match newlines) can be used:
+
address@hidden
+printf 'foo\nbar\n' | grep -P '(?s)foo.*?bar'
address@hidden example
+
+With the GNU @command{grep} option @code{-z} (@pxref{File and
+Directory Selection}), the input is terminated by null bytes.  Thus,
+you can match newlines in the input, but the output will be the whole
+file, so this is really only useful to determine if the pattern is
+present:
+
address@hidden
+printf 'foo\nbar\n' | grep -z -q 'foo[[:space:]]\+bar'
address@hidden example
+
+Failing either of those options, you need to transform the input
+before giving it to @command{grep}, or turn to @command{awk},
address@hidden, @command{perl}, or many other utilities that are
+designed to operate across lines.
 
 @item
 What do @command{grep}, @command{fgrep}, and @command{egrep} stand for?

-----------------------------------------------------------------------

Summary of changes:
 doc/grep.texi |   31 ++++++++++++++++++++++++++++++-
 1 files changed, 30 insertions(+), 1 deletions(-)


hooks/post-receive
-- 
grep



reply via email to

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