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 "May 3, 2013"
14 egrep \- search a file for a pattern using full regular expressions
18 \fB/usr/bin/egrep\fR [\fB-bcHhilnqsv\fR] \fB-e\fR \fIpattern_list\fR [\fIfile...\fR]
23 \fB/usr/bin/egrep\fR [\fB-bcHhilnqsv\fR] \fB-f\fR \fIfile\fR [\fIfile...\fR]
28 \fB/usr/bin/egrep\fR [\fB-bcHhilnqsv\fR] \fIpattern\fR [\fIfile...\fR]
33 \fB/usr/xpg4/bin/egrep\fR [\fB-bcHhilnqsvx\fR] \fB-e\fR \fIpattern_list\fR [\fB-f\fR \fIfile\fR]
39 \fB/usr/xpg4/bin/egrep\fR [\fB-bcHhilnqsvx\fR] [\fB-e\fR \fIpattern_list\fR] \fB-f\fR \fIfile\fR
45 \fB/usr/xpg4/bin/egrep\fR [\fB-bcHhilnqsvx\fR] \fIpattern\fR [\fIfile...\fR]
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.
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.
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:
71 A full regular expression followed by \fB+\fR that matches one or more
72 occurrences of the full regular expression.
77 A full regular expression followed by \fB?\fR that matches 0 or 1
78 occurrences of the full regular expression.
83 Full regular expressions separated by | or by a \fBNEWLINE\fR that match
84 strings that are matched by any of the expressions.
89 A full regular expression that can be enclosed in parentheses \fB()\fRfor
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).
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"
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
111 The following options are supported for both \fB/usr/bin/egrep\fR and
112 \fB/usr/xpg4/bin/egrep\fR:
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).
129 Print only a count of the lines that contain the pattern.
135 \fB\fB-e\fR \fIpattern_list\fR\fR
138 Search for a \fIpattern_list\fR (\fIfull regular expression\fR that begins with
145 \fB\fB-f\fR \fIfile\fR\fR
148 Take the list of \fIfull\fR \fIregular\fR \fIexpressions\fR from \fIfile\fR.
157 Precedes each line by the name of the file containing the matching line.
166 Suppress printing of filenames when searching multiple files.
175 Ignore upper/lower case distinction during comparisons.
184 Print the names of files with matching lines once, separated by NEWLINEs. Does
185 not repeat the names of files when the pattern is found more than once.
194 Precede each line by its line number in the file (first line is 1).
203 Quiet. Does not write anything to the standard output, regardless of matching
204 lines. Exits with zero status if an input line is selected.
213 Legacy equivalent of \fB-q\fR.
222 Print all lines except those that contain the pattern.
225 .SS "/usr/xpg4/bin/egrep"
228 The following options are supported for \fB/usr/xpg4/bin/egrep\fR only:
235 Consider only input lines that use all characters in the line to match an
236 entire fixed string or regular expression to be matching lines.
242 The following operands are supported:
249 A path name of a file to be searched for the patterns. If no \fIfile\fR
250 operands are specified, the standard input is used.
260 Specify a pattern to be used during the search for input.
263 .SS "/usr/xpg4/bin/egrep"
270 Specify one or more patterns to be used during the search for input. This
271 operand is treated as if it were specified as \fB-e\fR\fIpattern_list.\fR.
277 See \fBlargefile\fR(5) for the description of the behavior of \fBegrep\fR when
278 encountering files greater than or equal to 2 Gbyte ( 2^31 bytes).
279 .SH ENVIRONMENT VARIABLES
282 See \fBenviron\fR(5) for descriptions of the following environment variables
283 that affect the execution of \fBegrep\fR: \fBLC_COLLATE\fR, \fBLC_CTYPE\fR,
284 \fBLC_MESSAGES\fR, and \fBNLSPATH\fR.
288 The following exit values are returned:
295 If any matches are found.
304 If no matches are found.
313 For syntax errors or inaccessible files (even if matches were found).
319 See \fBattributes\fR(5) for descriptions of the following attributes:
328 ATTRIBUTE TYPE ATTRIBUTE VALUE
333 .SS "/usr/xpg4/bin/egrep"
341 ATTRIBUTE TYPE ATTRIBUTE VALUE
349 \fBfgrep\fR(1), \fBgrep\fR(1), \fBsed\fR(1), \fBsh\fR(1), \fBattributes\fR(5),
350 \fBenviron\fR(5), \fBlargefile\fR(5), \fBregex\fR(5), \fBregexp\fR(5),
355 Ideally there should be only one \fBgrep\fR command, but there is not a single
356 algorithm that spans a wide enough range of space-time trade-offs.
359 Lines are limited only by the size of the available virtual memory.
360 .SS "/usr/xpg4/bin/egrep"
363 The \fB/usr/xpg4/bin/egrep\fR utility is identical to \fB/usr/xpg4/bin/grep\fR
364 \fB-E\fR. See \fBgrep\fR(1). Portable applications should use
365 \fB/usr/xpg4/bin/grep\fR \fB-E\fR.