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/fgrep.1
          +++ new/usr/src/man/man1/fgrep.1
↓ open down ↓ 1 lines elided ↑ open up ↑
   2    2  .\" Copyright 1989 AT&T
   3    3  .\" Copyright (c) 2006, Sun Microsystems, Inc.  All Rights Reserved
   4    4  .\" Portions Copyright (c) 1992, X/Open Company Limited  All Rights Reserved
   5    5  .\" 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
   6    6  .\" http://www.opengroup.org/bookstore/.
   7    7  .\" 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.
   8    8  .\"  This notice shall appear on any product containing this material.
   9    9  .\" 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.
  10   10  .\" 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.
  11   11  .\" 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]
  12      -.TH FGREP 1 "May 3, 2013"
       12 +.TH FGREP 1 "Nov 28, 2017"
  13   13  .SH NAME
  14   14  fgrep \- search a file for a fixed-character string
  15   15  .SH SYNOPSIS
  16   16  .LP
  17   17  .nf
  18      -\fB/usr/bin/fgrep\fR [\fB-bcHhilnqsvx\fR] \fB-e\fR \fIpattern_list\fR [\fIfile...\fR]
  19      -.fi
  20      -
  21      -.LP
  22      -.nf
  23      -\fB/usr/bin/fgrep\fR [\fB-bcHhilnqsvx\fR] \fB-f\fR \fIfile\fR [\fIfile...\fR]
  24      -.fi
  25      -
  26      -.LP
  27      -.nf
  28      -\fB/usr/bin/fgrep\fR [\fB-bcHhilnqsvx\fR] \fIpattern\fR [\fIfile...\fR]
  29      -.fi
  30      -
  31      -.LP
  32      -.nf
  33      -\fB/usr/xpg4/bin/fgrep\fR [\fB-bcHhilnqsvx\fR] \fB-e\fR \fIpattern_list\fR [\fB-f\fR \fIfile\fR]
       18 +\fB/usr/bin/fgrep\fR [\fB-bcHhilnqsvx\fR] \fB-e\fR \fIpattern_list\fR [\fB-f\fR \fIfile\fR]
  34   19       [\fIfile...\fR]
  35   20  .fi
  36   21  
  37   22  .LP
  38   23  .nf
  39      -\fB/usr/xpg4/bin/fgrep\fR [\fB-bcHhilnqsvx\fR] [\fB-e\fR \fIpattern_list\fR] \fB-f\fR \fIfile\fR
       24 +\fB/usr/bin/fgrep\fR [\fB-bcHhilnqsvx\fR] [\fB-e\fR \fIpattern_list\fR] \fB-f\fR \fIfile\fR
  40   25       [\fIfile...\fR]
  41   26  .fi
  42   27  
  43   28  .LP
  44   29  .nf
  45      -\fB/usr/xpg4/bin/fgrep\fR [\fB-bcHhilnqsvx\fR] \fIpattern\fR [\fIfile...\fR]
       30 +\fB/usr/bin/fgrep\fR [\fB-bcHhilnqsvx\fR] \fIpattern\fR [\fIfile...\fR]
  46   31  .fi
  47   32  
  48   33  .SH DESCRIPTION
  49      -.sp
  50   34  .LP
  51   35  The \fBfgrep\fR (fast \fBgrep\fR) utility searches files for a character string
  52   36  and prints all lines that contain that string. \fBfgrep\fR is different from
  53   37  \fBgrep\fR(1) and from \fBegrep\fR(1) because it searches for a string, instead
  54   38  of searching for a pattern that matches an expression. \fBfgrep\fR uses a fast
  55   39  and compact algorithm.
  56   40  .sp
  57   41  .LP
  58   42  The characters \fB$\fR, \fB*\fR, \fB[\fR, \fB^\fR, |, \fB(\fR, \fB)\fR, and
  59   43  \fB\e\fR are interpreted literally by \fBfgrep\fR, that is, \fBfgrep\fR does
  60   44  not recognize full regular expressions as does \fBegrep\fR. These characters
  61   45  have special meaning to the shell. Therefore, to be safe, enclose the entire
  62   46  \fIstring\fR within single quotes (\fBa\'\fR).
  63   47  .sp
  64   48  .LP
  65   49  If no files are specified, \fBfgrep\fR assumes standard input. Normally, each
  66   50  line that is found is copied to the standard output. The file name is printed
  67   51  before each line that is found if there is more than one input file.
  68   52  .SH OPTIONS
  69      -.sp
  70   53  .LP
  71      -The following options are supported for both \fB/usr/bin/fgrep\fR and
  72      -\fB/usr/xpg4/bin/fgrep\fR:
       54 +The following options are supported:
  73   55  .sp
  74   56  .ne 2
  75   57  .na
  76   58  \fB\fB-b\fR\fR
  77   59  .ad
  78      -.RS 19n
       60 +.RS 6n
  79   61  Precedes each line by the block number on which the line was found. This can be
  80   62  useful in locating block numbers by context. The first block is 0.
  81   63  .RE
  82   64  
  83   65  .sp
  84   66  .ne 2
  85   67  .na
  86   68  \fB\fB-c\fR\fR
  87   69  .ad
  88      -.RS 19n
       70 +.RS 6n
  89   71  Prints only a count of the lines that contain the pattern.
  90   72  .RE
  91   73  
  92   74  .sp
  93   75  .ne 2
  94   76  .na
  95   77  \fB\fB-e\fR \fIpattern_list\fR\fR
  96   78  .ad
  97      -.RS 19n
       79 +.RS 6n
  98   80  Searches for a \fIstring\fR in \fIpattern-list\fR. This is useful when the
  99   81  \fIstring\fR begins with a \fB\(mi\fR\&.
 100   82  .RE
 101   83  
 102   84  .sp
 103   85  .ne 2
 104   86  .na
 105   87  \fB\fB-f\fR \fIpattern-file\fR\fR
 106   88  .ad
 107      -.RS 19n
       89 +.RS 6n
 108   90  Takes the list of patterns from \fIpattern-file\fR.
 109   91  .RE
 110   92  
 111   93  .sp
 112   94  .ne 2
 113   95  .na
 114   96  \fB\fB-H\fR\fR
 115   97  .ad
 116      -.RS 19n
       98 +.RS 6n
 117   99  Precedes each line by the name of the file containing the matching line.
 118  100  .RE
 119  101  
 120  102  .sp
 121  103  .ne 2
 122  104  .na
 123  105  \fB\fB-h\fR\fR
 124  106  .ad
 125      -.RS 19n
      107 +.RS 6n
 126  108  Suppresses printing of files when searching multiple files.
 127  109  .RE
 128  110  
 129  111  .sp
 130  112  .ne 2
 131  113  .na
 132  114  \fB\fB-i\fR\fR
 133  115  .ad
 134      -.RS 19n
      116 +.RS 6n
 135  117  Ignores upper/lower case distinction during comparisons.
 136  118  .RE
 137  119  
 138  120  .sp
 139  121  .ne 2
 140  122  .na
 141  123  \fB\fB-l\fR\fR
 142  124  .ad
 143      -.RS 19n
      125 +.RS 6n
 144  126  Prints the names of files with matching lines once, separated by new-lines.
 145  127  Does not repeat the names of files when the pattern is found more than once.
 146  128  .RE
 147  129  
 148  130  .sp
 149  131  .ne 2
 150  132  .na
 151  133  \fB\fB-n\fR\fR
 152  134  .ad
 153      -.RS 19n
      135 +.RS 6n
 154  136  Precedes each line by its line number in the file. The first line is 1.
 155  137  .RE
 156  138  
 157  139  .sp
 158  140  .ne 2
 159  141  .na
 160  142  \fB\fB-q\fR\fR
 161  143  .ad
 162      -.RS 19n
      144 +.RS 6n
 163  145  Quiet. Does not write anything to the standard output, regardless of matching
 164  146  lines. Exits with zero status if an input line is selected.
 165  147  .RE
 166  148  
 167  149  .sp
 168  150  .ne 2
 169  151  .na
 170  152  \fB\fB-s\fR\fR
 171  153  .ad
 172      -.RS 19n
      154 +.RS 6n
 173  155  Legacy equivalent of \fB-q\fR.
 174  156  .RE
 175  157  
 176  158  .sp
 177  159  .ne 2
 178  160  .na
 179  161  \fB\fB-v\fR\fR
 180  162  .ad
 181      -.RS 19n
      163 +.RS 6n
 182  164  Prints all lines except those that contain the pattern.
 183  165  .RE
 184  166  
 185  167  .sp
 186  168  .ne 2
 187  169  .na
 188  170  \fB\fB-x\fR\fR
 189  171  .ad
 190      -.RS 19n
      172 +.RS 6n
 191  173  Prints only lines that are matched entirely.
 192  174  .RE
 193  175  
 194  176  .SH OPERANDS
 195      -.sp
 196  177  .LP
 197  178  The following operands are supported:
 198  179  .sp
 199  180  .ne 2
 200  181  .na
 201  182  \fB\fIfile\fR\fR
 202  183  .ad
 203  184  .RS 8n
 204  185  Specifies a path name of a file to be searched for the patterns. If no
 205  186  \fIfile\fR operands are specified, the standard input will be used.
 206  187  .RE
 207  188  
 208      -.SS "/usr/bin/fgrep"
 209      -.sp
 210      -.ne 2
 211      -.na
 212      -\fB\fIpattern\fR\fR
 213      -.ad
 214      -.RS 11n
 215      -Specifies a pattern to be used during the search for input.
 216      -.RE
 217      -
 218      -.SS "/usr/xpg4/bin/fgrep"
 219      -.sp
 220  189  .ne 2
 221  190  .na
 222  191  \fB\fIpattern\fR\fR
 223  192  .ad
 224      -.RS 11n
      193 +.RS 8n
 225  194  Specifies one or more patterns to be used during the search for input. This
 226  195  operand is treated as if it were specified as \fB-e\fR \fIpattern_list\fR.
 227  196  .RE
 228  197  
 229  198  .SH USAGE
 230      -.sp
 231  199  .LP
 232  200  See \fBlargefile\fR(5) for the description of the behavior of \fBfgrep\fR when
 233  201  encountering files greater than or equal to 2 Gbyte ( 2^31 bytes).
 234  202  .SH ENVIRONMENT VARIABLES
 235      -.sp
 236  203  .LP
 237  204  See \fBenviron\fR(5) for descriptions of the following environment variables
 238  205  that affect the execution of \fBfgrep\fR: \fBLC_COLLATE\fR, \fBLC_CTYPE\fR,
 239  206  \fBLC_MESSAGES\fR, and \fBNLSPATH\fR.
 240  207  .SH EXIT STATUS
 241      -.sp
 242  208  .LP
 243  209  The following exit values are returned:
 244  210  .sp
 245  211  .ne 2
 246  212  .na
 247  213  \fB\fB0\fR\fR
 248  214  .ad
 249  215  .RS 5n
 250  216  If any matches are found
 251  217  .RE
↓ open down ↓ 9 lines elided ↑ open up ↑
 261  227  
 262  228  .sp
 263  229  .ne 2
 264  230  .na
 265  231  \fB\fB2\fR\fR
 266  232  .ad
 267  233  .RS 5n
 268  234  For syntax errors or inaccessible files, even if matches were found.
 269  235  .RE
 270  236  
 271      -.SS "/usr/xpg4/bin/fgrep"
 272      -.sp
 273      -
 274  237  .SH ATTRIBUTES
 275      -.sp
 276  238  .LP
 277  239  See \fBattributes\fR(5) for descriptions of the following attributes:
 278  240  .sp
 279  241  .TS
 280  242  box;
 281  243  c | c
 282  244  l | l .
 283  245  ATTRIBUTE TYPE  ATTRIBUTE VALUE
 284  246  _
 285  247  CSI     Enabled
 286  248  .TE
 287  249  
 288  250  .SH SEE ALSO
 289      -.sp
 290  251  .LP
 291  252  \fBed\fR(1), \fBegrep\fR(1), \fBgrep\fR(1), \fBsed\fR(1), \fBsh\fR(1),
 292  253  \fBattributes\fR(5), \fBenviron\fR(5), \fBlargefile\fR(5), \fBXPG4\fR(5)
 293  254  .SH NOTES
 294      -.sp
 295  255  .LP
 296  256  Ideally, there should be only one \fBgrep\fR command, but there is not a single
 297  257  algorithm that spans a wide enough range of space-time tradeoffs.
 298  258  .sp
 299  259  .LP
 300  260  Lines are limited only by the size of the available virtual memory.
 301      -.SS "/usr/xpg4/bin/fgrep"
 302      -.sp
 303  261  .LP
 304      -The \fB/usr/xpg4/bin/fgrep\fR utility is identical to \fB/usr/xpg4/bin/grep\fR
      262 +The \fB/usr/bin/fgrep\fR utility is identical to \fB/usr/bin/grep\fR
 305  263  \fB-F\fR (see \fBgrep\fR(1)). Portable applications should use
 306      -\fB/usr/xpg4/bin/grep\fR \fB-F\fR.
      264 +\fB/usr/bin/grep\fR \fB-F\fR.
      265 +.LP
      266 +In the past the behavior of \fB/usr/xpg4/bin/fgrep\fR and
      267 +\fB/usr/bin/fgrep\fR utilities was different. Now \fB/usr/bin/fgrep\fR
      268 +is replaced by \fB/usr/xpg4/bin/fgrep\fR.
    
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX