Print this page
8858 /usr/bin/grep doesn't support -E option
4580 /usr/bin/grep can't handle multibyte characters
8929 8868 tests are not delivered with system/test/utiltest
8860 Example in grep(1) is incorrect
Reviewed by: Peter Tribble <peter.tribble@gmail.com>
Reviewed by: Toomas Soome <tsoome@me.com>
Reviewed by: Yuri Pankov <yuripv@gmx.com>

Split Close
Expand all
Collapse all
          --- old/usr/src/man/man1/grep.1
          +++ new/usr/src/man/man1/grep.1
↓ open down ↓ 2 lines elided ↑ open up ↑
   3    3  .\" Copyright 1989 AT&T
   4    4  .\" Copyright (c) 2008, Sun Microsystems, Inc.  All Rights Reserved
   5    5  .\" Portions Copyright (c) 1992, X/Open Company Limited  All Rights Reserved
   6    6  .\" Sun Microsystems, Inc. gratefully acknowledges The Open Group for permission to reproduce portions of its copyrighted documentation. Original documentation from The Open Group can be obtained online at
   7    7  .\" http://www.opengroup.org/bookstore/.
   8    8  .\" The Institute of Electrical and Electronics Engineers and The Open Group, have given us permission to reprint portions of their documentation. In the following statement, the phrase "this text" refers to portions of the system documentation. Portions of this text are reprinted and reproduced in electronic form in the Sun OS Reference Manual, from IEEE Std 1003.1, 2004 Edition, Standard for Information Technology -- Portable Operating System Interface (POSIX), The Open Group Base Specifications Issue 6, Copyright (C) 2001-2004 by the Institute of Electrical and Electronics Engineers, Inc and The Open Group. In the event of any discrepancy between these versions and the original IEEE and The Open Group Standard, the original IEEE and The Open Group Standard is the referee document. The original Standard can be obtained online at http://www.opengroup.org/unix/online.html.
   9    9  .\"  This notice shall appear on any product containing this material.
  10   10  .\" The contents of this file are subject to the terms of the Common Development and Distribution License (the "License").  You may not use this file except in compliance with the License.
  11   11  .\" You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE or http://www.opensolaris.org/os/licensing.  See the License for the specific language governing permissions and limitations under the License.
  12   12  .\" When distributing Covered Code, include this CDDL HEADER in each file and include the License file at usr/src/OPENSOLARIS.LICENSE.  If applicable, add the following below this CDDL HEADER, with the fields enclosed by brackets "[]" replaced with your own identifying information: Portions Copyright [yyyy] [name of copyright owner]
  13      -.TH GREP 1 "June 5, 2017"
       13 +.TH GREP 1 "Nov 28, 2017"
  14   14  .SH NAME
  15   15  grep \- search a file for a pattern
  16   16  .SH SYNOPSIS
  17   17  .LP
  18   18  .nf
  19      -\fB/usr/bin/grep\fR [\fB-c\fR | \fB-l\fR |\fB-q\fR] [\fB-r\fR | \fB-R\fR] [\fB-bHhinsvw\fR]
  20      -    \fIlimited-regular-expression\fR [\fIfilename\fR]...
  21      -.fi
  22      -
  23      -.LP
  24      -.nf
  25      -\fB/usr/xpg4/bin/grep\fR [\fB-E\fR | \fB-F\fR] [\fB-c\fR | \fB-l\fR | \fB-q\fR] [\fB-r\fR | \fB-R\fR]
       19 +\fB/usr/bin/grep\fR [\fB-E\fR | \fB-F\fR] [\fB-c\fR | \fB-l\fR | \fB-q\fR] [\fB-r\fR | \fB-R\fR]
  26   20      [\fB-bHhinsvwx\fR] [\fB-A\fR \fInumber\fR] [\fB-B\fR \fInumber\fR] [\fB-C\fR \fInumber\fR | \fB-\fR\fInumber\fR] \fB-e\fR \fIpattern_list\fR... [\fB-f\fR \fIpattern_file\fR]...
  27   21      [\fIfile\fR]...
  28   22  .fi
  29   23  
  30   24  .LP
  31   25  .nf
  32      -\fB/usr/xpg4/bin/grep\fR [\fB-E\fR | \fB-F\fR] [\fB-c\fR | \fB-l\fR | \fB-q\fR] [\fB-r\fR | \fB-R\fR]
       26 +\fB/usr/bin/grep\fR [\fB-E\fR | \fB-F\fR] [\fB-c\fR | \fB-l\fR | \fB-q\fR] [\fB-r\fR | \fB-R\fR]
  33   27      [\fB-bHhinsvwx\fR] [\fB-A\fR \fInumber\fR] [\fB-B\fR \fInumber\fR] [\fB-C\fR \fInumber\fR | \fB-\fR\fInumber\fR] [\fB-e\fR \fIpattern_list\fR]... \fB-f\fR \fIpattern_file\fR...
  34   28      [\fIfile\fR]...
  35   29  .fi
  36   30  
  37   31  .LP
  38   32  .nf
  39      -\fB/usr/xpg4/bin/grep\fR [\fB-E\fR | \fB-F\fR] [\fB-c\fR | \fB-l\fR | \fB-q\fR] [\fB-r\fR | \fB-R\fR]
       33 +\fB/usr/bin/grep\fR [\fB-E\fR | \fB-F\fR] [\fB-c\fR | \fB-l\fR | \fB-q\fR] [\fB-r\fR | \fB-R\fR]
  40   34      [\fB-bHhinsvwx\fR] [\fB-A\fR \fInumber\fR] [\fB-B\fR \fInumber\fR] [\fB-C\fR \fInumber\fR | \fB-\fR\fInumber\fR] \fIpattern\fR [\fIfile\fR]...
  41   35  .fi
  42   36  
  43   37  .SH DESCRIPTION
  44   38  .LP
  45   39  The \fBgrep\fR utility searches text files for a pattern and prints all lines
  46   40  that contain that pattern.  It uses a compact non-deterministic algorithm.
  47   41  .sp
  48   42  .LP
  49   43  Be careful using the characters \fB$\fR, \fB*\fR, \fB[\fR, \fB^\fR, \fB|\fR,
  50   44  \fB(\fR, \fB)\fR, and \fB\e\fR in the \fIpattern_list\fR because they are also
  51   45  meaningful to the shell. It is safest to enclose the entire \fIpattern_list\fR
  52   46  in single quotes \fB\'\fR\&...\fB\'\fR\&.
  53   47  .sp
  54   48  .LP
  55   49  If no files are specified, \fBgrep\fR assumes standard input. Normally, each
  56   50  line found is copied to standard output. The file name is printed before each
  57   51  line found if there is more than one input file.
  58      -.SS "/usr/bin/grep"
  59   52  .LP
  60      -The \fB/usr/bin/grep\fR utility uses limited regular expressions like those
  61      -described on the \fBregexp\fR(5) manual page to match the patterns.
  62      -.SS "/usr/xpg4/bin/grep"
  63      -.LP
  64      -The options \fB-E\fR and \fB-F\fR affect the way \fB/usr/xpg4/bin/grep\fR
       53 +The options \fB-E\fR and \fB-F\fR affect the way \fBgrep\fR
  65   54  interprets \fIpattern_list\fR. If \fB-E\fR is specified,
  66      -\fB/usr/xpg4/bin/grep\fR interprets \fIpattern_list\fR as a full regular
       55 +\fBgrep\fR interprets \fIpattern_list\fR as a full regular
  67   56  expression (see \fB-E\fR for description).  If \fB-F\fR is specified,
  68   57  \fBgrep\fR interprets \fIpattern_list\fR as a fixed string. If neither are
  69   58  specified, \fBgrep\fR interprets \fIpattern_list\fR as a basic regular
  70   59  expression as described on \fBregex\fR(5) manual page.
  71   60  .SH OPTIONS
  72   61  .LP
  73      -The following options are supported for both \fB/usr/bin/grep\fR and
  74      -\fB/usr/xpg4/bin/grep\fR:
       62 +The following options are supported:
       63 +.sp
       64 +.ne 2
       65 +.na
       66 +\fB\fB-A\fR \fInumber\fR\fR
       67 +.ad
       68 +.RS 6n
       69 +Prints \fInumber\fR input lines of context after each matching line. If there
       70 +are multiple matching lines, their context lines are separated by a \fB--\fR
       71 +delimiter line.
       72 +.RE
       73 +
  75   74  .sp
  76   75  .ne 2
  77   76  .na
  78   77  \fB\fB-b\fR\fR
  79   78  .ad
  80   79  .RS 6n
  81   80  Precedes each line by the block number on which it was found. This can be
  82   81  useful in locating block numbers by context (first block is 0).
  83   82  .RE
  84   83  
  85   84  .sp
  86   85  .ne 2
  87   86  .na
  88      -\fB\fB-c\fR\fR
       87 +\fB\fB-B\fR \fInumber\fR\fR
  89   88  .ad
  90   89  .RS 6n
  91      -Prints only a count of the lines that contain the pattern.
       90 +Prints \fInumber\fR input lines of context before each matching line. If there
       91 +are multiple matching lines, their context lines are separated by a \fB--\fR
       92 +delimiter line.
  92   93  .RE
  93   94  
  94   95  .sp
  95   96  .ne 2
  96   97  .na
  97      -\fB\fB-H\fR\fR
       98 +\fB\fB-c\fR\fR
  98   99  .ad
  99  100  .RS 6n
 100      -Precedes each line by the name of the file containing the matching line.
      101 +Prints only a count of the lines that contain the pattern.
 101  102  .RE
 102  103  
 103  104  .sp
 104  105  .ne 2
 105  106  .na
 106      -\fB\fB-h\fR\fR
      107 +\fB\fB-H\fR\fR
 107  108  .ad
 108  109  .RS 6n
 109      -Prevents the name of the file containing the matching line from being prepended
 110      -to that line.  Used when searching multiple files.
      110 +Precedes each line by the name of the file containing the matching line.
 111  111  .RE
 112  112  
 113  113  .sp
 114  114  .ne 2
 115  115  .na
 116      -\fB\fB-i\fR\fR
      116 +\fB\fB-e\fR \fIpattern_list\fR\fR
 117  117  .ad
 118  118  .RS 6n
 119      -Ignores upper/lower case distinction during comparisons.
      119 +Specifies one or more patterns to be used during the search for input. Patterns
      120 +in \fIpattern_list\fR must be separated by a NEWLINE character. A null pattern
      121 +can be specified by two adjacent newline characters in \fIpattern_list\fR.
      122 +Unless the \fB-E\fR or \fB-F\fR option is also specified, each pattern is
      123 +treated as a basic regular expression.  Multiple \fB-e\fR and \fB-f\fR options
      124 +are accepted by \fBgrep\fR. All of the specified patterns are used when
      125 +matching lines, but the order of evaluation is unspecified.
 120  126  .RE
 121  127  
 122  128  .sp
 123  129  .ne 2
 124  130  .na
 125      -\fB\fB-l\fR\fR
      131 +\fB\fB-E\fR\fR
 126  132  .ad
 127  133  .RS 6n
 128      -Prints only the names of files with matching lines, separated by NEWLINE
 129      -characters.  Does not repeat the names of files when the pattern is found more
 130      -than once.
      134 +Matches using full regular expressions. Treats each pattern specified as a full
      135 +regular expression. If any entire full regular expression pattern matches an
      136 +input line, the line is matched. A null full regular expression matches every
      137 +line. Each pattern is interpreted as a full regular expression as described on
      138 +the \fBregex\fR(5) manual page, except for \fB\e(\fR and \fB\e)\fR, and
      139 +including:
      140 +.RS +4
      141 +.TP
      142 +1.
      143 +A full regular expression followed by \fB+\fR that matches one or more
      144 +occurrences of the full regular expression.
      145 +.RE
      146 +.RS +4
      147 +.TP
      148 +2.
      149 +A full regular expression followed by \fB?\fR that matches 0 or 1
      150 +occurrences of the full regular expression.
      151 +.RE
      152 +.RS +4
      153 +.TP
      154 +3.
      155 +Full regular expressions separated by | or by a new-line that match strings
      156 +that are matched by any of the expressions.
      157 +.RE
      158 +.RS +4
      159 +.TP
      160 +4.
      161 +A full regular expression that is enclosed in parentheses \fB()\fR for
      162 +grouping.
      163 +.RE
      164 +The order of precedence of operators is \fB[\|]\fR, then \fB*\|?\|+\fR, then
      165 +concatenation, then | and new-line.
 131  166  .RE
 132  167  
 133  168  .sp
 134  169  .ne 2
 135  170  .na
 136      -\fB\fB-n\fR\fR
      171 +\fB\fB-f\fR \fIpattern_file\fR\fR
 137  172  .ad
 138  173  .RS 6n
 139      -Precedes each line by its line number in the file (first line is 1).
      174 +Reads one or more patterns from the file named by the path name
      175 +\fIpattern_file\fR. Patterns in \fIpattern_file\fR are terminated by a NEWLINE
      176 +character. A null pattern can be specified by an empty line in
      177 +\fIpattern_file\fR. Unless the \fB-E\fR or \fB-F\fR option is also specified,
      178 +each pattern is treated as a basic regular expression.
 140  179  .RE
 141  180  
 142  181  .sp
 143  182  .ne 2
 144  183  .na
 145      -\fB\fB-r\fR\fR
      184 +\fB\fB-F\fR\fR
 146  185  .ad
 147  186  .RS 6n
 148      -Read all files under each directory, recursively. Follow symbolic links on
 149      -the command line, but skip symlinks that are encountered recursively. If file
 150      -is a device, FIFO, or socket, skip it.
      187 +Matches using fixed strings. Treats each pattern specified as a string instead
      188 +of a regular expression. If an input line contains any of the patterns as a
      189 +contiguous sequence of bytes, the line is matched. A null string matches every
      190 +line. See \fBfgrep\fR(1) for more information.
 151  191  .RE
 152  192  
 153  193  .sp
 154  194  .ne 2
 155  195  .na
 156      -\fB\fB-R\fR\fR
      196 +\fB\fB-h\fR\fR
 157  197  .ad
 158  198  .RS 6n
 159      -Read all files under each directory, recursively, following all symbolic links.
      199 +Prevents the name of the file containing the matching line from being prepended
      200 +to that line.  Used when searching multiple files.
 160  201  .RE
 161  202  
 162  203  .sp
 163  204  .ne 2
 164  205  .na
 165      -\fB\fB-q\fR\fR
      206 +\fB\fB-i\fR\fR
 166  207  .ad
 167  208  .RS 6n
 168      -Quiet. Does not write anything to the standard output, regardless of matching
 169      -lines. Exits with zero status if an input line is selected.
      209 +Ignores upper/lower case distinction during comparisons.
 170  210  .RE
 171  211  
 172  212  .sp
 173  213  .ne 2
 174  214  .na
 175      -\fB\fB-s\fR\fR
      215 +\fB\fB-l\fR\fR
 176  216  .ad
 177  217  .RS 6n
 178      -Suppresses error messages about nonexistent or unreadable files.
      218 +Prints only the names of files with matching lines, separated by NEWLINE
      219 +characters.  Does not repeat the names of files when the pattern is found more
      220 +than once.
 179  221  .RE
 180  222  
 181  223  .sp
 182  224  .ne 2
 183  225  .na
 184      -\fB\fB-v\fR\fR
      226 +\fB\fB-n\fR\fR
 185  227  .ad
 186  228  .RS 6n
 187      -Prints all lines except those that contain the pattern.
      229 +Precedes each line by its line number in the file (first line is 1).
 188  230  .RE
 189  231  
 190  232  .sp
 191  233  .ne 2
 192  234  .na
 193      -\fB\fB-w\fR\fR
      235 +\fB\fB-r\fR\fR
 194  236  .ad
 195  237  .RS 6n
 196      -Searches for the expression as a word as if surrounded by \fB\e<\fR and
 197      -\fB\e>\fR\&.
      238 +Read all files under each directory, recursively. Follow symbolic links on
      239 +the command line, but skip symlinks that are encountered recursively. If file
      240 +is a device, FIFO, or socket, skip it.
 198  241  .RE
 199  242  
 200      -.SS "/usr/xpg4/bin/grep"
 201      -.LP
 202      -The following options are supported for \fB/usr/xpg4/bin/grep\fR only:
 203  243  .sp
 204  244  .ne 2
 205  245  .na
 206      -\fB\fB-A\fR \fInumber\fR\fR
      246 +\fB\fB-R\fR\fR
 207  247  .ad
 208      -.RS 19n
 209      -Prints \fInumber\fR input lines of context after each matching line. If there
 210      -are multiple matching lines, their context lines are separated by a \fB--\fR
 211      -delimiter line.
      248 +.RS 6n
      249 +Read all files under each directory, recursively, following all symbolic links.
 212  250  .RE
 213  251  
 214  252  .sp
 215  253  .ne 2
 216  254  .na
 217      -\fB\fB-B\fR \fInumber\fR\fR
      255 +\fB\fB-q\fR\fR
 218  256  .ad
 219      -.RS 19n
 220      -Prints \fInumber\fR input lines of context before each matching line. If there
 221      -are multiple matching lines, their context lines are separated by a \fB--\fR
 222      -delimiter line.
      257 +.RS 6n
      258 +Quiet. Does not write anything to the standard output, regardless of matching
      259 +lines. Exits with zero status if an input line is selected.
 223  260  .RE
 224  261  
 225  262  .sp
 226  263  .ne 2
 227  264  .na
 228  265  \fB\fB-\fR\fInumber\fR\fR
 229  266  .ad
 230  267  .br
 231  268  .na
 232  269  \fB\fB-C\fR \fInumber\fR\fR
 233  270  .ad
 234      -.RS 19n
      271 +.RS 6n
 235  272  Prints \fInumber\fR input lines of context before and \fInumber\fR input lines
 236  273  of context after each matching line. If there are multiple matching lines,
 237  274  their context lines are separated by a \fB--\fR delimiter line.
 238  275  .RE
 239  276  
 240      -
 241  277  .sp
 242  278  .ne 2
 243  279  .na
 244      -\fB\fB-e\fR \fIpattern_list\fR\fR
 245      -.ad
 246      -.RS 19n
 247      -Specifies one or more patterns to be used during the search for input. Patterns
 248      -in \fIpattern_list\fR must be separated by a NEWLINE character. A null pattern
 249      -can be specified by two adjacent newline characters in \fIpattern_list\fR.
 250      -Unless the \fB-E\fR or \fB-F\fR option is also specified, each pattern is
 251      -treated as a basic regular expression.  Multiple \fB-e\fR and \fB-f\fR options
 252      -are accepted by \fBgrep\fR. All of the specified patterns are used when
 253      -matching lines, but the order of evaluation is unspecified.
 254      -.RE
 255      -
 256      -.sp
 257      -.ne 2
 258      -.na
 259      -\fB\fB-E\fR\fR
      280 +\fB\fB-s\fR\fR
 260  281  .ad
 261      -.RS 19n
 262      -Matches using full regular expressions. Treats each pattern specified as a full
 263      -regular expression. If any entire full regular expression pattern matches an
 264      -input line, the line is matched. A null full regular expression matches every
 265      -line. Each pattern is interpreted as a full regular expression as described on
 266      -the \fBregex\fR(5) manual page, except for \fB\e(\fR and \fB\e)\fR, and
 267      -including:
 268      -.RS +4
 269      -.TP
 270      -1.
 271      -A full regular expression followed by \fB+\fR that matches one or more
 272      -occurrences of the full regular expression.
 273      -.RE
 274      -.RS +4
 275      -.TP
 276      -2.
 277      -A full regular expression followed by \fB?\fR that matches 0 or 1
 278      -occurrences of the full regular expression.
 279      -.RE
 280      -.RS +4
 281      -.TP
 282      -3.
 283      -Full regular expressions separated by | or by a new-line that match strings
 284      -that are matched by any of the expressions.
 285      -.RE
 286      -.RS +4
 287      -.TP
 288      -4.
 289      -A full regular expression that is enclosed in parentheses \fB()\fR for
 290      -grouping.
 291      -.RE
 292      -The order of precedence of operators is \fB[\|]\fR, then \fB*\|?\|+\fR, then
 293      -concatenation, then | and new-line.
      282 +.RS 6n
      283 +Suppresses error messages about nonexistent or unreadable files.
 294  284  .RE
 295  285  
 296  286  .sp
 297  287  .ne 2
 298  288  .na
 299      -\fB\fB-f\fR \fIpattern_file\fR\fR
      289 +\fB\fB-v\fR\fR
 300  290  .ad
 301      -.RS 19n
 302      -Reads one or more patterns from the file named by the path name
 303      -\fIpattern_file\fR. Patterns in \fIpattern_file\fR are terminated by a NEWLINE
 304      -character. A null pattern can be specified by an empty line in
 305      -\fIpattern_file\fR. Unless the \fB-E\fR or \fB-F\fR option is also specified,
 306      -each pattern is treated as a basic regular expression.
      291 +.RS 6n
      292 +Prints all lines except those that contain the pattern.
 307  293  .RE
 308  294  
 309  295  .sp
 310  296  .ne 2
 311  297  .na
 312      -\fB\fB-F\fR\fR
      298 +\fB\fB-w\fR\fR
 313  299  .ad
 314      -.RS 19n
 315      -Matches using fixed strings. Treats each pattern specified as a string instead
 316      -of a regular expression. If an input line contains any of the patterns as a
 317      -contiguous sequence of bytes, the line is matched. A null string matches every
 318      -line. See \fBfgrep\fR(1) for more information.
      300 +.RS 6n
      301 +Searches for the expression as a word as if surrounded by \fB\e<\fR and
      302 +\fB\e>\fR\&.
 319  303  .RE
 320  304  
 321  305  .sp
 322  306  .ne 2
 323  307  .na
 324  308  \fB\fB-x\fR\fR
 325  309  .ad
 326      -.RS 19n
      310 +.RS 6n
 327  311  Considers only input lines that use all characters in the line to match an
 328  312  entire fixed string or regular expression to be matching lines.
 329  313  .RE
 330  314  
 331  315  .SH OPERANDS
 332  316  .LP
 333  317  The following operands are supported:
 334  318  .sp
 335  319  .ne 2
 336  320  .na
 337  321  \fB\fIfile\fR\fR
 338  322  .ad
 339  323  .RS 8n
 340  324  A path name of a file to be searched for the patterns. If no \fIfile\fR
 341  325  operands are specified, the standard input is used.
 342  326  .RE
 343  327  
 344      -.SS "/usr/bin/grep"
 345      -.ne 2
 346      -.na
 347      -\fB\fIpattern\fR\fR
 348      -.ad
 349      -.RS 11n
 350      -Specifies a pattern to be used during the search for input.
 351      -.RE
 352      -
 353      -.SS "/usr/xpg4/bin/grep"
 354  328  .ne 2
 355  329  .na
 356  330  \fB\fIpattern\fR\fR
 357  331  .ad
 358      -.RS 11n
      332 +.RS 8n
 359  333  Specifies one or more patterns to be used during the search for input. This
 360  334  operand is treated as if it were specified as \fB-e\fR \fIpattern_list\fR.
 361  335  .RE
 362  336  
 363  337  .SH USAGE
 364  338  .LP
 365  339  The \fB-e\fR \fIpattern_list\fR option has the same effect as the
 366  340  \fIpattern_list\fR operand, but is useful when \fIpattern_list\fR begins with
 367  341  the hyphen delimiter. It is also useful when it is more convenient to provide
 368  342  multiple patterns as separate arguments.
↓ open down ↓ 61 lines elided ↑ open up ↑
 430  404  .LP
 431  405  \fBExample 3 \fRFinding Lines Containing Strings
 432  406  .sp
 433  407  .LP
 434  408  All of the following commands print all lines containing strings \fBabc\fR or
 435  409  \fBdef\fR or both:
 436  410  
 437  411  .sp
 438  412  .in +2
 439  413  .nf
 440      -example% \fB/usr/xpg4/bin/grep 'abc
      414 +example% \fB/usr/bin/grep 'abc
 441  415  def'\fR
 442      -example% \fB/usr/xpg4/bin/grep -e 'abc
      416 +example% \fB/usr/bin/grep -e 'abc
 443  417  def'\fR
 444      -example% \fB/usr/xpg4/bin/grep -e 'abc' -e 'def'\fR
 445      -example% \fB/usr/xpg4/bin/grep -E 'abc|def'\fR
 446      -example% \fB/usr/xpg4/bin/grep -E -e 'abc|def'\fR
 447      -example% \fB/usr/xpg4/bin/grep -E -e 'abc' -e 'def'\fR
 448      -example% \fB/usr/xpg4/bin/grep -E 'abc
      418 +example% \fB/usr/bin/grep -e 'abc' -e 'def'\fR
      419 +example% \fB/usr/bin/grep -E 'abc|def'\fR
      420 +example% \fB/usr/bin/grep -E -e 'abc|def'\fR
      421 +example% \fB/usr/bin/grep -E -e 'abc' -e 'def'\fR
      422 +example% \fB/usr/bin/grep -E 'abc
 449  423  def'\fR
 450      -example% \fB/usr/xpg4/bin/grep -E -e 'abc
      424 +example% \fB/usr/bin/grep -E -e 'abc
 451  425  def'\fR
 452      -example% \fB/usr/xpg4/bin/grep -F -e 'abc' -e 'def'\fR
 453      -example% \fB/usr/xpg4/bin/grep -F 'abc
      426 +example% \fB/usr/bin/grep -F -e 'abc' -e 'def'\fR
      427 +example% \fB/usr/bin/grep -F 'abc
 454  428  def'\fR
 455      -example% \fB/usr/xpg4/bin/grep -F -e 'abc
      429 +example% \fB/usr/bin/grep -F -e 'abc
 456  430  def'\fR
 457  431  .fi
 458  432  .in -2
 459  433  .sp
 460  434  
 461  435  .LP
 462  436  \fBExample 4 \fRFinding Lines with Matching Strings
 463  437  .sp
 464  438  .LP
 465  439  Both of the following commands print all lines matching exactly \fBabc\fR or
 466  440  \fBdef\fR:
 467  441  
 468  442  .sp
 469  443  .in +2
 470  444  .nf
 471      -example% \fB/usr/xpg4/bin/grep -E '^abc$ ^def$'\fR
 472      -example% \fB/usr/xpg4/bin/grep -F -x 'abc def'\fR
      445 +example% \fB/usr/bin/grep -E '^abc$
      446 +^def$'\fR
      447 +example% \fB/usr/bin/grep -F -x 'abc
      448 +def'\fR
 473  449  .fi
 474  450  .in -2
 475  451  .sp
 476  452  
 477  453  .SH ENVIRONMENT VARIABLES
 478  454  .LP
 479  455  See \fBenviron\fR(5) for descriptions of the following environment variables
 480  456  that affect the execution of \fBgrep\fR: \fBLANG\fR, \fBLC_ALL\fR,
 481  457  \fBLC_COLLATE\fR, \fBLC_CTYPE\fR, \fBLC_MESSAGES\fR, and \fBNLSPATH\fR.
 482  458  .SH EXIT STATUS
↓ open down ↓ 22 lines elided ↑ open up ↑
 505  481  .na
 506  482  \fB\fB2\fR\fR
 507  483  .ad
 508  484  .RS 5n
 509  485  Syntax errors or inaccessible files (even if matches were found).
 510  486  .RE
 511  487  
 512  488  .SH ATTRIBUTES
 513  489  .LP
 514  490  See \fBattributes\fR(5) for descriptions of the following attributes:
 515      -.SS "/usr/bin/grep"
 516      -
 517      -.TS
 518      -box;
 519      -c | c
 520      -l | l .
 521      -ATTRIBUTE TYPE  ATTRIBUTE VALUE
 522      -_
 523      -CSI     Not Enabled
 524      -.TE
 525      -
 526      -.SS "/usr/xpg4/bin/grep"
 527  491  
 528  492  .TS
 529  493  box;
 530  494  c | c
 531  495  l | l .
 532  496  ATTRIBUTE TYPE  ATTRIBUTE VALUE
 533  497  _
 534  498  CSI     Enabled
 535  499  _
 536  500  Interface Stability     Committed
 537  501  _
 538  502  Standard        See \fBstandards\fR(5).
 539  503  .TE
 540  504  
 541  505  .SH SEE ALSO
 542  506  .LP
 543  507  \fBegrep\fR(1), \fBfgrep\fR(1), \fBsed\fR(1), \fBsh\fR(1), \fBattributes\fR(5),
 544  508  \fBenviron\fR(5), \fBlargefile\fR(5), \fBregex\fR(5), \fBregexp\fR(5),
 545  509  \fBstandards\fR(5)
 546  510  .SH NOTES
 547      -.SS "/usr/bin/grep"
 548      -.LP
 549      -Lines are limited only by the size of the available virtual memory. If there is
 550      -a line with embedded nulls, \fBgrep\fR only matches up to the first null. If
 551      -the line matches, the entire line is printed.
 552      -.SS "/usr/xpg4/bin/grep"
 553  511  .LP
 554  512  The results are unspecified if input files contain lines longer than
 555  513  \fBLINE_MAX\fR bytes or contain binary data. \fBLINE_MAX\fR is defined in
 556  514  \fB/usr/include/limits.h\fR.
      515 +.LP
      516 +In the past the behavior of \fB/usr/xpg4/bin/grep\fR and
      517 +\fB/usr/bin/grep\fR utilities was different. Now \fB/usr/bin/grep\fR
      518 +is replaced by \fB/usr/xpg4/bin/grep\fR.
    
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX