grep-commit
[Top][All Lists]
Advanced

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

Changes to grep/manual/grep.txt,v


From: Jim Meyering
Subject: Changes to grep/manual/grep.txt,v
Date: Tue, 21 Sep 2010 06:07:08 +0000

CVSROOT:        /webcvs/grep
Module name:    grep
Changes by:     Jim Meyering <meyering> 10/09/21 06:07:07

Index: grep.txt
===================================================================
RCS file: /webcvs/grep/grep/manual/grep.txt,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -b -r1.5 -r1.6
--- grep.txt    2 Apr 2010 10:26:52 -0000       1.5
+++ grep.txt    21 Sep 2010 06:07:06 -0000      1.6
@@ -35,7 +35,7 @@
 
 `grep' prints lines that match a pattern.
 
-   This manual is for version 2.6.3 of GNU Grep.
+   This manual is for version 2.7 of GNU Grep.
 
    This manual is for `grep', a pattern matching engine.
 
@@ -620,11 +620,9 @@
      behaves more like other GNU programs.  POSIX.2 requires that
      options that follow file names must be treated as file names; by
      default, such options are permuted to the front of the operand list
-     and are treated as options.  Also, POSIX.2 requires that
-     unrecognized options be diagnosed as "illegal", but since they are
-     not really against the law the default is to diagnose them as
-     "invalid".  `POSIXLY_CORRECT' also disables
-     `_N_GNU_nonoption_argv_flags_', described below.
+     and are treated as options.  Also, `POSIXLY_CORRECT' disables
+     special handling of an invalid bracket expression.  *Note
+     invalid-bracket-expr::.
 
 `_N_GNU_nonoption_argv_flags_'
      (Here `N' is `grep''s numeric process ID.)  If the Ith character
@@ -810,7 +808,8 @@
 
 `[:space:]'
      Space characters: tab, newline, vertical tab, form feed, carriage
-     return, and space.
+     return, and space.  *Note Usage::, for more discussion of matching
+     newlines.
 
 `[:upper:]'
      Upper-case letters: `A B C D E F G H I J K L M N O P Q R S T U V W
@@ -826,6 +825,12 @@
 be included in addition to the brackets delimiting the bracket
 expression.)
 
+   If you mistakenly omit the outer brackets, and search for say,
+`[:upper:]', GNU `grep' prints a diagnostic and exits with status 2, on
+the assumption that you did not intend to search for the nominally
+equivalent regular expression: `[:epru]'.  Set the `POSIXLY_CORRECT'
+environment variable to disable this feature.
+
    Most meta-characters lose their special meaning inside bracket
 expressions.
 
@@ -886,6 +891,12 @@
 ``\W''
      Match non-word constituent, it is a synonym for `[^[:alnum:]]'.
 
+``\s''
+     Match whitespace, it is a synonym for `[[:space:]]'.
+
+``\S''
+     Match non-whitespace, it is a synonym for `[^[:space:]]'.
+
 
    For example, `\brat\b' matches the separate word `rat', `\Brat\B'
 matches `crate' but not `furry rat'.
@@ -1079,10 +1090,32 @@
      match, as there is no `aa' in the input, so the `\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
+     match if the first alternate has matched--making the second one
      superfluous.)
 
- 14. What do `grep', `fgrep', and `egrep' stand for?
+ 14. How can I match across lines?
+
+     Standard grep cannot do this, as it is fundamentally line-based.
+     Therefore, merely using the `[: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 `s' modifier
+     (which makes `.' match newlines) can be used:
+
+          printf 'foo\nbar\n' | grep -P '(?s)foo.*?bar'
+
+     With the GNU `grep' option `-z' (*note 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:
+
+          printf 'foo\nbar\n' | grep -z -q 'foo[[:space:]]\+bar'
+
+     Failing either of those options, you need to transform the input
+     before giving it to `grep', or turn to `awk', `sed', `perl', or
+     many other utilities that are designed to operate across lines.
+
+ 15. What do `grep', `fgrep', and `egrep' stand for?
 
      The name `grep' comes from the way line editing was done on Unix.
      For example, `ed' uses the following syntax to print a list of
@@ -1622,10 +1655,10 @@
 Index
 *****
 
-*:                                             See 3.1.      (line  724)
-+:                                             See 3.1.      (line  727)
+*:                                             See 3.1.      (line  722)
++:                                             See 3.1.      (line  725)
 --after-context:                               See 2.1.5.    (line  322)
---basic-regexp:                                See 2.4.      (line  663)
+--basic-regexp:                                See 2.4.      (line  661)
 --before-context:                              See 2.1.5.    (line  326)
 --binary:                                      See 2.1.7.    (line  438)
 --binary-files:                                See 2.1.6.    (line  364)
@@ -1639,11 +1672,11 @@
 --exclude:                                     See 2.1.6.    (line  395)
 --exclude-dir:                                 See 2.1.6.    (line  404)
 --exclude-from:                                See 2.1.6.    (line  400)
---extended-regexp:                             See 2.4.      (line  668)
+--extended-regexp:                             See 2.4.      (line  666)
 --file:                                        See 2.1.2.    (line  116)
 --files-with-matches:                          See 2.1.3.    (line  179)
 --files-without-match:                         See 2.1.3.    (line  173)
---fixed-strings:                               See 2.4.      (line  673)
+--fixed-strings:                               See 2.4.      (line  671)
 --group-separator:                             See 2.1.5.    (line  334)
 --help:                                        See 2.1.1.    (line   96)
 --ignore-case:                                 See 2.1.2.    (line  123)
@@ -1661,7 +1694,7 @@
 --null:                                        See 2.1.4.    (line  302)
 --null-data:                                   See 2.1.7.    (line  452)
 --only-matching:                               See 2.1.3.    (line  219)
---perl-regexp:                                 See 2.4.      (line  679)
+--perl-regexp:                                 See 2.4.      (line  677)
 --quiet:                                       See 2.1.3.    (line  225)
 --recursive:                                   See 2.1.6.    (line  418)
 --regexp=PATTERN:                              See 2.1.2.    (line  110)
@@ -1679,11 +1712,11 @@
 -c:                                            See 2.1.3.    (line  152)
 -d:                                            See 2.1.6.    (line  385)
 -D:                                            See 2.1.6.    (line  378)
--E:                                            See 2.4.      (line  668)
+-E:                                            See 2.4.      (line  666)
 -e:                                            See 2.1.2.    (line  110)
--F:                                            See 2.4.      (line  673)
+-F:                                            See 2.4.      (line  671)
 -f:                                            See 2.1.2.    (line  116)
--G:                                            See 2.4.      (line  663)
+-G:                                            See 2.4.      (line  661)
 -h:                                            See 2.1.4.    (line  264)
 -H:                                            See 2.1.4.    (line  259)
 -i:                                            See 2.1.2.    (line  123)
@@ -1693,7 +1726,7 @@
 -n:                                            See 2.1.4.    (line  277)
 -NUM:                                          See 2.1.5.    (line  331)
 -o:                                            See 2.1.3.    (line  219)
--P:                                            See 2.4.      (line  679)
+-P:                                            See 2.4.      (line  677)
 -q:                                            See 2.1.3.    (line  225)
 -r:                                            See 2.1.6.    (line  418)
 -s:                                            See 2.1.3.    (line  232)
@@ -1707,73 +1740,73 @@
 -y:                                            See 2.1.2.    (line  123)
 -z:                                            See 2.1.7.    (line  452)
 -Z:                                            See 2.1.4.    (line  302)
-.:                                             See 3.1.      (line  718)
-?:                                             See 3.1.      (line  721)
-_N_GNU_nonoption_argv_flags_ environment variable:See 2.2.   (line  630)
+.:                                             See 3.1.      (line  716)
+?:                                             See 3.1.      (line  719)
+_N_GNU_nonoption_argv_flags_ environment variable:See 2.2.   (line  628)
 after context:                                 See 2.1.5.    (line  322)
-alnum character class:                         See 3.2.      (line  781)
-alpha character class:                         See 3.2.      (line  784)
-alphabetic characters:                         See 3.2.      (line  784)
-alphanumeric characters:                       See 3.2.      (line  781)
-anchoring:                                     See 3.4.      (line  896)
-asterisk:                                      See 3.1.      (line  724)
-back-reference:                                See 3.5.      (line  902)
-backslash:                                     See 3.3.      (line  868)
-basic regular expressions:                     See 3.6.      (line  914)
+alnum character class:                         See 3.2.      (line  779)
+alpha character class:                         See 3.2.      (line  782)
+alphabetic characters:                         See 3.2.      (line  782)
+alphanumeric characters:                       See 3.2.      (line  779)
+anchoring:                                     See 3.4.      (line  907)
+asterisk:                                      See 3.1.      (line  722)
+back-reference:                                See 3.5.      (line  913)
+backslash:                                     See 3.3.      (line  873)
+basic regular expressions:                     See 3.6.      (line  925)
 before context:                                See 2.1.5.    (line  326)
 binary files:                                  See 2.1.6.    (line  360)
 binary files, MS-DOS/MS-Windows:               See 2.1.7.    (line  438)
-blank character class:                         See 3.2.      (line  787)
-blank characters:                              See 3.2.      (line  787)
+blank character class:                         See 3.2.      (line  785)
+blank characters:                              See 3.2.      (line  785)
 bn GREP_COLORS capability:                     See 2.2.      (line  558)
-braces, first argument omitted:                See 3.1.      (line  736)
-braces, one argument:                          See 3.1.      (line  730)
-braces, second argument omitted:               See 3.1.      (line  733)
-braces, two arguments:                         See 3.1.      (line  739)
-bracket expression:                            See 3.2.      (line  758)
-Bugs, known:                                   See 5.1.      (line 1109)
-bugs, reporting:                               See 5.        (line 1101)
+braces, first argument omitted:                See 3.1.      (line  734)
+braces, one argument:                          See 3.1.      (line  728)
+braces, second argument omitted:               See 3.1.      (line  731)
+braces, two arguments:                         See 3.1.      (line  737)
+bracket expression:                            See 3.2.      (line  756)
+Bugs, known:                                   See 5.1.      (line 1142)
+bugs, reporting:                               See 5.        (line 1134)
 byte offset:                                   See 2.1.4.    (line  251)
 byte offsets, on MS-DOS/MS-Windows:            See 2.1.4.    (line  292)
 case insensitive search:                       See 2.1.2.    (line  123)
 changing name of standard input:               See 2.1.4.    (line  269)
-character class:                               See 3.2.      (line  758)
-character classes:                             See 3.2.      (line  780)
+character class:                               See 3.2.      (line  756)
+character classes:                             See 3.2.      (line  778)
 character type:                                See 2.2.      (line  600)
-classes of characters:                         See 3.2.      (line  780)
-cntrl character class:                         See 3.2.      (line  790)
+classes of characters:                         See 3.2.      (line  778)
+cntrl character class:                         See 3.2.      (line  788)
 context:                                       See 2.1.5.    (line  331)
 context lines, after match:                    See 2.1.5.    (line  322)
 context lines, before match:                   See 2.1.5.    (line  326)
-control characters:                            See 3.2.      (line  790)
-copying:                                       See 6.        (line 1119)
+control characters:                            See 3.2.      (line  788)
+copying:                                       See 6.        (line 1152)
 counting lines:                                See 2.1.3.    (line  152)
 cx GREP_COLORS capability:                     See 2.2.      (line  511)
 default options environment variable:          See 2.2.      (line  474)
 device search:                                 See 2.1.6.    (line  378)
-digit character class:                         See 3.2.      (line  795)
-digit characters:                              See 3.2.      (line  795)
+digit character class:                         See 3.2.      (line  793)
+digit characters:                              See 3.2.      (line  793)
 directory search:                              See 2.1.6.    (line  385)
-dot:                                           See 3.1.      (line  718)
+dot:                                           See 3.1.      (line  716)
 environment variables:                         See 2.2.      (line  473)
 exclude directories:                           See 2.1.6.    (line  404)
 exclude files:                                 See 2.1.6.    (line  395)
-exit status:                                   See 2.3.      (line  643)
-FAQ about grep usage:                          See 4.        (line  944)
+exit status:                                   See 2.3.      (line  641)
+FAQ about grep usage:                          See 4.        (line  955)
 files which don't match:                       See 2.1.3.    (line  173)
 fn GREP_COLORS capability:                     See 2.2.      (line  548)
-graph character class:                         See 3.2.      (line  798)
-graphic characters:                            See 3.2.      (line  798)
-grep programs:                                 See 2.4.      (line  655)
+graph character class:                         See 3.2.      (line  796)
+graphic characters:                            See 3.2.      (line  796)
+grep programs:                                 See 2.4.      (line  653)
 GREP_COLOR environment variable:               See 2.2.      (line  484)
 GREP_COLORS environment variable:              See 2.2.      (line  495)
 GREP_OPTIONS environment variable:             See 2.2.      (line  474)
 group separator:                               See 2.1.5.    (line  334)
-hexadecimal digits:                            See 3.2.      (line  820)
+hexadecimal digits:                            See 3.2.      (line  819)
 highlight markers:                             See 2.2.      (line  484)
 highlight, color, colour:                      See 2.1.3.    (line  158)
 include files:                                 See 2.1.6.    (line  412)
-interval specifications:                       See 3.6.      (line  918)
+interval specifications:                       See 3.6.      (line  929)
 invert matching:                               See 2.1.2.    (line  129)
 LANG environment variable:                     See 2.2.      (line  600)
 language of messages:                          See 2.2.      (line  614)
@@ -1784,20 +1817,20 @@
 line buffering:                                See 2.1.7.    (line  427)
 line numbering:                                See 2.1.4.    (line  277)
 ln GREP_COLORS capability:                     See 2.2.      (line  553)
-lower character class:                         See 3.2.      (line  801)
-lower-case letters:                            See 3.2.      (line  801)
-match expression at most M times:              See 3.1.      (line  736)
-match expression at most once:                 See 3.1.      (line  721)
-match expression from N to M times:            See 3.1.      (line  739)
-match expression N or more times:              See 3.1.      (line  733)
-match expression N times:                      See 3.1.      (line  730)
-match expression one or more times:            See 3.1.      (line  727)
-match expression zero or more times:           See 3.1.      (line  724)
+lower character class:                         See 3.2.      (line  799)
+lower-case letters:                            See 3.2.      (line  799)
+match expression at most M times:              See 3.1.      (line  734)
+match expression at most once:                 See 3.1.      (line  719)
+match expression from N to M times:            See 3.1.      (line  737)
+match expression N or more times:              See 3.1.      (line  731)
+match expression N times:                      See 3.1.      (line  728)
+match expression one or more times:            See 3.1.      (line  725)
+match expression zero or more times:           See 3.1.      (line  722)
 match the whole line:                          See 2.1.2.    (line  143)
-matching basic regular expressions:            See 2.4.      (line  663)
-matching extended regular expressions:         See 2.4.      (line  668)
-matching fixed strings:                        See 2.4.      (line  673)
-matching Perl regular expressions:             See 2.4.      (line  679)
+matching basic regular expressions:            See 2.4.      (line  661)
+matching extended regular expressions:         See 2.4.      (line  666)
+matching fixed strings:                        See 2.4.      (line  671)
+matching Perl regular expressions:             See 2.4.      (line  677)
 matching whole words:                          See 2.1.2.    (line  134)
 max-count:                                     See 2.1.3.    (line  186)
 mc GREP_COLORS capability:                     See 2.2.      (line  541)
@@ -1812,50 +1845,50 @@
 ne GREP_COLORS capability:                     See 2.2.      (line  570)
 NLS:                                           See 2.2.      (line  600)
 no filename prefix:                            See 2.1.4.    (line  264)
-numeric characters:                            See 3.2.      (line  795)
+numeric characters:                            See 3.2.      (line  793)
 only matching:                                 See 2.1.3.    (line  219)
-palindromes:                                   See 4.        (line 1056)
+palindromes:                                   See 4.        (line 1067)
 pattern from file:                             See 2.1.2.    (line  116)
 pattern list:                                  See 2.1.2.    (line  110)
-period:                                        See 3.1.      (line  718)
-plus sign:                                     See 3.1.      (line  727)
+period:                                        See 3.1.      (line  716)
+plus sign:                                     See 3.1.      (line  725)
 POSIXLY_CORRECT environment variable:          See 2.2.      (line  619)
-print character class:                         See 3.2.      (line  805)
+print character class:                         See 3.2.      (line  803)
 print non-matching lines:                      See 2.1.2.    (line  129)
-printable characters:                          See 3.2.      (line  805)
-punct character class:                         See 3.2.      (line  808)
-punctuation characters:                        See 3.2.      (line  808)
-question mark:                                 See 3.1.      (line  721)
+printable characters:                          See 3.2.      (line  803)
+punct character class:                         See 3.2.      (line  806)
+punctuation characters:                        See 3.2.      (line  806)
+question mark:                                 See 3.1.      (line  719)
 quiet, silent:                                 See 2.1.3.    (line  225)
-range expression:                              See 3.2.      (line  764)
+range expression:                              See 3.2.      (line  762)
 recursive search:                              See 2.1.6.    (line  418)
-regular expressions:                           See 3.        (line  693)
-return status:                                 See 2.3.      (line  643)
+regular expressions:                           See 3.        (line  691)
+return status:                                 See 2.3.      (line  641)
 rv GREP_COLORS capability:                     See 2.2.      (line  520)
 searching directory trees:                     See 2.1.6.    (line  395)
 searching for a pattern:                       See 1.        (line   55)
 sl GREP_COLORS capability:                     See 2.2.      (line  503)
-space character class:                         See 3.2.      (line  812)
-space characters:                              See 3.2.      (line  812)
-subexpression:                                 See 3.5.      (line  902)
+space character class:                         See 3.2.      (line  810)
+space characters:                              See 3.2.      (line  810)
+subexpression:                                 See 3.5.      (line  913)
 suppress binary data:                          See 2.1.6.    (line  360)
 suppress error messages:                       See 2.1.3.    (line  232)
 tab-aligned content lines:                     See 2.1.4.    (line  282)
 translation of message language:               See 2.2.      (line  614)
-upper character class:                         See 3.2.      (line  816)
-upper-case letters:                            See 3.2.      (line  816)
+upper character class:                         See 3.2.      (line  815)
+upper-case letters:                            See 3.2.      (line  815)
 usage summary, printing:                       See 2.1.1.    (line   96)
-usage, examples:                               See 4.        (line  933)
-using grep, Q&A:                               See 4.        (line  944)
-variants of gerp:                              See 2.4.      (line  655)
+usage, examples:                               See 4.        (line  944)
+using grep, Q&A:                               See 4.        (line  955)
+variants of gerp:                              See 2.4.      (line  653)
 version, printing:                             See 2.1.1.    (line  101)
-whitespace characters:                         See 3.2.      (line  812)
+whitespace characters:                         See 3.2.      (line  810)
 with filename prefix:                          See 2.1.4.    (line  259)
-xdigit character class:                        See 3.2.      (line  820)
-xdigit class:                                  See 3.2.      (line  820)
+xdigit character class:                        See 3.2.      (line  819)
+xdigit class:                                  See 3.2.      (line  819)
 zero-terminated file names:                    See 2.1.4.    (line  302)
 zero-terminated lines:                         See 2.1.7.    (line  452)
-{,M}:                                          See 3.1.      (line  736)
-{N,M}:                                         See 3.1.      (line  739)
-{N,}:                                          See 3.1.      (line  733)
-{N}:                                           See 3.1.      (line  730)
+{,M}:                                          See 3.1.      (line  734)
+{N,M}:                                         See 3.1.      (line  737)
+{N,}:                                          See 3.1.      (line  731)
+{N}:                                           See 3.1.      (line  728)



reply via email to

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