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 EGREP 1 "Mar 24, 2006"
  13 .SH NAME
  14 egrep \- search a file for a pattern using full regular expressions
  15 .SH SYNOPSIS
  16 .LP
  17 .nf
  18 \fB/usr/bin/egrep\fR [\fB-bchilnsv\fR] \fB-e\fR \fIpattern_list\fR [\fIfile...\fR]
  19 .fi
  20 
  21 .LP
  22 .nf
  23 \fB/usr/bin/egrep\fR [\fB-bchilnsv\fR] \fB-f\fR \fIfile\fR [\fIfile...\fR]
  24 .fi
  25 
  26 .LP
  27 .nf
  28 \fB/usr/bin/egrep\fR [\fB-bchilnsv\fR] \fIpattern\fR [\fIfile...\fR]
  29 .fi
  30 
  31 .LP
  32 .nf
  33 \fB/usr/xpg4/bin/egrep\fR [\fB-bchilnqsvx\fR] \fB-e\fR \fIpattern_list\fR [\fB-f\fR \fIfile\fR]
  34      [\fIfile...\fR]
  35 .fi
  36 
  37 .LP
  38 .nf
  39 \fB/usr/xpg4/bin/egrep\fR [\fB-bchilnqsvx\fR] [\fB-e\fR \fIpattern_list\fR] \fB-f\fR \fIfile\fR
  40      [\fIfile...\fR]
  41 .fi
  42 
  43 .LP
  44 .nf
  45 \fB/usr/xpg4/bin/egrep\fR [\fB-bchilnqsvx\fR] \fIpattern\fR [\fIfile...\fR]
  46 .fi
  47 
  48 .SH DESCRIPTION
  49 .sp
  50 .LP
  51 The \fBegrep\fR (\fIexpression grep\fR) utility searches files for a pattern of
  52 characters and prints all lines that contain that pattern. \fBegrep\fR uses
  53 full regular expressions (expressions that have string values that use the full
  54 set of alphanumeric and special characters) to match the patterns. It uses a
  55 fast deterministic algorithm that sometimes needs exponential space.
  56 .sp
  57 .LP
  58 If no files are specified, \fBegrep\fR assumes standard input. Normally, each
  59 line found is copied to the standard output. The file name is printed before
  60 each line found if there is more than one input file.
  61 .SS "/usr/bin/egrep"
  62 .sp
  63 .LP
  64 The \fB/usr/bin/egrep\fR utility accepts full regular expressions as described
  65 on the \fBregexp\fR(5) manual page, except for \fB\e(\fR and \fB\e)\fR,
  66 \fB\e(\fR and \fB\e)\fR, \fB\e{\fR and \fB\e}\fR, \fB\e<\fR and \fB\e>\fR, and
  67 \fB\en\fR, and with the addition of:
  68 .RS +4
  69 .TP
  70 1.
  71 A full regular expression followed by \fB+\fR that matches one or more
  72 occurrences of the full regular expression.
  73 .RE
  74 .RS +4
  75 .TP
  76 2.
  77 A full regular expression followed by \fB?\fR that matches 0 or 1
  78 occurrences of the full regular expression.
  79 .RE
  80 .RS +4
  81 .TP
  82 3.
  83 Full regular expressions separated by | or by a \fBNEWLINE\fR that match
  84 strings that are matched by any of the expressions.
  85 .RE
  86 .RS +4
  87 .TP
  88 4.
  89 A full regular expression that can be enclosed in parentheses \fB()\fRfor
  90 grouping.
  91 .RE
  92 .sp
  93 .LP
  94 Be careful using the characters \fB$\fR, \fB*\fR, \fB[\fR, \fB^\fR, |, \fB(\fR,
  95 \fB)\fR, and \fB\e\fR in \fIfull regular expression\fR, because they are also
  96 meaningful to the shell. It is safest to enclose the entire \fIfull regular
  97 expression\fR in single quotes (\fBa\'\fR\fBa\'\fR).
  98 .sp
  99 .LP
 100 The order of precedence of operators is \fB[\|]\fR, then \fB*\|?\|+\fR, then
 101 concatenation, then | and NEWLINE.
 102 .SS "/usr/xpg4/bin/egrep"
 103 .sp
 104 .LP
 105 The \fB/usr/xpg4/bin/egrep\fR utility uses the regular expressions described in
 106 the \fBEXTENDED REGULAR EXPRESSIONS\fR section of the \fBregex\fR(5) manual
 107 page.
 108 .SH OPTIONS
 109 .sp
 110 .LP
 111 The following options are supported for both \fB/usr/bin/egrep\fR and
 112 \fB/usr/xpg4/bin/egrep\fR:
 113 .sp
 114 .ne 2
 115 .na
 116 \fB\fB-b\fR\fR
 117 .ad
 118 .RS 19n
 119 Precede each line by the block number on which it was found. This can be useful
 120 in locating block numbers by context (first block is 0).
 121 .RE
 122 
 123 .sp
 124 .ne 2
 125 .na
 126 \fB\fB-c\fR\fR
 127 .ad
 128 .RS 19n
 129 Print only a count of the lines that contain the pattern.
 130 .RE
 131 
 132 .sp
 133 .ne 2
 134 .na
 135 \fB\fB-e\fR \fIpattern_list\fR\fR
 136 .ad
 137 .RS 19n
 138 Search for a \fIpattern_list\fR (\fIfull regular expression\fR that begins with
 139 a \fB\(mi\fR).
 140 .RE
 141 
 142 .sp
 143 .ne 2
 144 .na
 145 \fB\fB-f\fR \fIfile\fR\fR
 146 .ad
 147 .RS 19n
 148 Take the list of \fIfull\fR \fIregular\fR \fIexpressions\fR from \fIfile\fR.
 149 .RE
 150 
 151 .sp
 152 .ne 2
 153 .na
 154 \fB\fB-h\fR\fR
 155 .ad
 156 .RS 19n
 157 Suppress printing of filenames when searching multiple files.
 158 .RE
 159 
 160 .sp
 161 .ne 2
 162 .na
 163 \fB\fB-i\fR\fR
 164 .ad
 165 .RS 19n
 166 Ignore upper/lower case distinction during comparisons.
 167 .RE
 168 
 169 .sp
 170 .ne 2
 171 .na
 172 \fB\fB-l\fR\fR
 173 .ad
 174 .RS 19n
 175 Print the names of files with matching lines once, separated by NEWLINEs. Does
 176 not repeat the names of files when the pattern is found more than once.
 177 .RE
 178 
 179 .sp
 180 .ne 2
 181 .na
 182 \fB\fB-n\fR\fR
 183 .ad
 184 .RS 19n
 185 Precede each line by its line number in the file (first line is 1).
 186 .RE
 187 
 188 .sp
 189 .ne 2
 190 .na
 191 \fB\fB-s\fR\fR
 192 .ad
 193 .RS 19n
 194 Work silently, that is, display nothing except error messages. This is useful
 195 for checking the error status.
 196 .RE
 197 
 198 .sp
 199 .ne 2
 200 .na
 201 \fB\fB-v\fR\fR
 202 .ad
 203 .RS 19n
 204 Print all lines except those that contain the pattern.
 205 .RE
 206 
 207 .SS "/usr/xpg4/bin/egrep"
 208 .sp
 209 .LP
 210 The following options are supported for \fB/usr/xpg4/bin/egrep\fR only:
 211 .sp
 212 .ne 2
 213 .na
 214 \fB\fB-q\fR\fR
 215 .ad
 216 .RS 6n
 217 Quiet. Does not write anything to the standard output, regardless of matching
 218 lines. Exits with zero status if an input line is selected.
 219 .RE
 220 
 221 .sp
 222 .ne 2
 223 .na
 224 \fB\fB-x\fR\fR
 225 .ad
 226 .RS 6n
 227 Consider only input lines that use all characters in the line to match an
 228 entire fixed string or regular expression to be matching lines.
 229 .RE
 230 
 231 .SH OPERANDS
 232 .sp
 233 .LP
 234 The following operands are supported:
 235 .sp
 236 .ne 2
 237 .na
 238 \fB\fIfile\fR\fR
 239 .ad
 240 .RS 8n
 241 A path name of a file to be searched for the patterns. If no \fIfile\fR
 242 operands are specified, the standard input is used.
 243 .RE
 244 
 245 .SS "/usr/bin/egrep"
 246 .sp
 247 .ne 2
 248 .na
 249 \fB\fIpattern\fR\fR
 250 .ad
 251 .RS 11n
 252 Specify a pattern to be used during the search for input.
 253 .RE
 254 
 255 .SS "/usr/xpg4/bin/egrep"
 256 .sp
 257 .ne 2
 258 .na
 259 \fB\fIpattern\fR\fR
 260 .ad
 261 .RS 11n
 262 Specify one or more patterns to be used during the search for input. This
 263 operand is treated as if it were specified as \fB-e\fR\fIpattern_list.\fR.
 264 .RE
 265 
 266 .SH USAGE
 267 .sp
 268 .LP
 269 See \fBlargefile\fR(5) for the description of the behavior of \fBegrep\fR when
 270 encountering files greater than or equal to 2 Gbyte ( 2^31 bytes).
 271 .SH ENVIRONMENT VARIABLES
 272 .sp
 273 .LP
 274 See \fBenviron\fR(5) for descriptions of the following environment variables
 275 that affect the execution of \fBegrep\fR: \fBLC_COLLATE\fR, \fBLC_CTYPE\fR,
 276 \fBLC_MESSAGES\fR, and \fBNLSPATH\fR.
 277 .SH EXIT STATUS
 278 .sp
 279 .LP
 280 The following exit values are returned:
 281 .sp
 282 .ne 2
 283 .na
 284 \fB\fB0\fR\fR
 285 .ad
 286 .RS 5n
 287 If any matches are found.
 288 .RE
 289 
 290 .sp
 291 .ne 2
 292 .na
 293 \fB\fB1\fR\fR
 294 .ad
 295 .RS 5n
 296 If no matches are found.
 297 .RE
 298 
 299 .sp
 300 .ne 2
 301 .na
 302 \fB\fB2\fR\fR
 303 .ad
 304 .RS 5n
 305 For syntax errors or inaccessible files (even if matches were found).
 306 .RE
 307 
 308 .SH ATTRIBUTES
 309 .sp
 310 .LP
 311 See \fBattributes\fR(5) for descriptions of the following attributes:
 312 .SS "/usr/bin/egrep"
 313 .sp
 314 
 315 .sp
 316 .TS
 317 box;
 318 c | c
 319 l | l .
 320 ATTRIBUTE TYPE  ATTRIBUTE VALUE
 321 _
 322 CSI     Not Enabled
 323 .TE
 324 
 325 .SS "/usr/xpg4/bin/egrep"
 326 .sp
 327 
 328 .sp
 329 .TS
 330 box;
 331 c | c
 332 l | l .
 333 ATTRIBUTE TYPE  ATTRIBUTE VALUE
 334 _
 335 CSI     Enabled
 336 .TE
 337 
 338 .SH SEE ALSO
 339 .sp
 340 .LP
 341 \fBfgrep\fR(1), \fBgrep\fR(1), \fBsed\fR(1), \fBsh\fR(1), \fBattributes\fR(5),
 342 \fBenviron\fR(5), \fBlargefile\fR(5), \fBregex\fR(5), \fBregexp\fR(5),
 343 \fBXPG4\fR(5)
 344 .SH NOTES
 345 .sp
 346 .LP
 347 Ideally there should be only one \fBgrep\fR command, but there is not a single
 348 algorithm that spans a wide enough range of space-time trade-offs.
 349 .sp
 350 .LP
 351 Lines are limited only by the size of the available virtual memory.
 352 .SS "/usr/xpg4/bin/egrep"
 353 .sp
 354 .LP
 355 The \fB/usr/xpg4/bin/egrep\fR utility is identical to \fB/usr/xpg4/bin/grep\fR
 356 \fB-E\fR. See \fBgrep\fR(1). Portable applications should use
 357 \fB/usr/xpg4/bin/grep\fR \fB-E\fR.