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