1egrep(1) User Commands egrep(1)
2
3
4
6 egrep - search a file for a pattern using full regular expressions
7
9 /usr/bin/egrep [-bchilnsv] -e pattern_list [file...]
10
11
12 /usr/bin/egrep [-bchilnsv] -f file [file...]
13
14
15 /usr/bin/egrep [-bchilnsv] pattern [file...]
16
17
18 /usr/xpg4/bin/egrep [-bchilnqsvx] -e pattern_list [-f file]
19 [file...]
20
21
22 /usr/xpg4/bin/egrep [-bchilnqsvx] [-e pattern_list] -f file
23 [file...]
24
25
26 /usr/xpg4/bin/egrep [-bchilnqsvx] pattern [file...]
27
28
30 The egrep (expression grep) utility searches files for a pattern of
31 characters and prints all lines that contain that pattern. egrep uses
32 full regular expressions (expressions that have string values that use
33 the full set of alphanumeric and special characters) to match the pat‐
34 terns. It uses a fast deterministic algorithm that sometimes needs
35 exponential space.
36
37
38 If no files are specified, egrep assumes standard input. Normally, each
39 line found is copied to the standard output. The file name is printed
40 before each line found if there is more than one input file.
41
42 /usr/bin/egrep
43 The /usr/bin/egrep utility accepts full regular expressions as
44 described on the regexp(5) manual page, except for \( and \), \( and
45 \), \{ and \}, \< and \>, and \n, and with the addition of:
46
47 1. A full regular expression followed by + that matches one or
48 more occurrences of the full regular expression.
49
50 2. A full regular expression followed by ? that matches 0 or 1
51 occurrences of the full regular expression.
52
53 3. Full regular expressions separated by | or by a NEWLINE that
54 match strings that are matched by any of the expressions.
55
56 4. A full regular expression that can be enclosed in parenthe‐
57 ses ()for grouping.
58
59
60 Be careful using the characters $, *, [, ^, |, (, ), and \ in full reg‐
61 ular expression, because they are also meaningful to the shell. It is
62 safest to enclose the entire full regular expression in single quotes
63 (a´a´).
64
65
66 The order of precedence of operators is [], then *?+, then concatena‐
67 tion, then | and NEWLINE.
68
69 /usr/xpg4/bin/egrep
70 The /usr/xpg4/bin/egrep utility uses the regular expressions described
71 in the EXTENDED REGULAR EXPRESSIONS section of the regex(5) manual
72 page.
73
75 The following options are supported for both /usr/bin/egrep and
76 /usr/xpg4/bin/egrep:
77
78 -b Precede each line by the block number on which it
79 was found. This can be useful in locating block num‐
80 bers by context (first block is 0).
81
82
83 -c Print only a count of the lines that contain the
84 pattern.
85
86
87 -e pattern_list Search for a pattern_list (full regular expression
88 that begins with a −).
89
90
91 -f file Take the list of full regular expressions from file.
92
93
94 -h Suppress printing of filenames when searching multi‐
95 ple files.
96
97
98 -i Ignore upper/lower case distinction during compar‐
99 isons.
100
101
102 -l Print the names of files with matching lines once,
103 separated by NEWLINEs. Does not repeat the names of
104 files when the pattern is found more than once.
105
106
107 -n Precede each line by its line number in the file
108 (first line is 1).
109
110
111 -s Work silently, that is, display nothing except error
112 messages. This is useful for checking the error sta‐
113 tus.
114
115
116 -v Print all lines except those that contain the pat‐
117 tern.
118
119
120 /usr/xpg4/bin/egrep
121 The following options are supported for /usr/xpg4/bin/egrep only:
122
123 -q Quiet. Does not write anything to the standard output, regardless
124 of matching lines. Exits with zero status if an input line is
125 selected.
126
127
128 -x Consider only input lines that use all characters in the line to
129 match an entire fixed string or regular expression to be matching
130 lines.
131
132
134 The following operands are supported:
135
136 file A path name of a file to be searched for the patterns. If no
137 file operands are specified, the standard input is used.
138
139
140 /usr/bin/egrep
141 pattern Specify a pattern to be used during the search for input.
142
143
144 /usr/xpg4/bin/egrep
145 pattern Specify one or more patterns to be used during the search
146 for input. This operand is treated as if it were specified
147 as -epattern_list..
148
149
151 See largefile(5) for the description of the behavior of egrep when
152 encountering files greater than or equal to 2 Gbyte ( 2^31 bytes).
153
155 See environ(5) for descriptions of the following environment variables
156 that affect the execution of egrep: LC_COLLATE, LC_CTYPE, LC_MESSAGES,
157 and NLSPATH.
158
160 The following exit values are returned:
161
162 0 If any matches are found.
163
164
165 1 If no matches are found.
166
167
168 2 For syntax errors or inaccessible files (even if matches were
169 found).
170
171
173 See attributes(5) for descriptions of the following attributes:
174
175 /usr/bin/egrep
176 ┌─────────────────────────────┬─────────────────────────────┐
177 │ ATTRIBUTE TYPE │ ATTRIBUTE VALUE │
178 ├─────────────────────────────┼─────────────────────────────┤
179 │Availability │SUNWcsu │
180 ├─────────────────────────────┼─────────────────────────────┤
181 │CSI │Not Enabled │
182 └─────────────────────────────┴─────────────────────────────┘
183
184 /usr/xpg4/bin/egrep
185 ┌─────────────────────────────┬─────────────────────────────┐
186 │ ATTRIBUTE TYPE │ ATTRIBUTE VALUE │
187 ├─────────────────────────────┼─────────────────────────────┤
188 │Availability │SUNWxcu4 │
189 ├─────────────────────────────┼─────────────────────────────┤
190 │CSI │Enabled │
191 └─────────────────────────────┴─────────────────────────────┘
192
194 fgrep(1), grep(1), sed(1), sh(1), attributes(5), environ(5), large‐
195 file(5), regex(5), regexp(5), XPG4(5)
196
198 Ideally there should be only one grep command, but there is not a sin‐
199 gle algorithm that spans a wide enough range of space-time trade-offs.
200
201
202 Lines are limited only by the size of the available virtual memory.
203
204 /usr/xpg4/bin/egrep
205 The /usr/xpg4/bin/egrep utility is identical to /usr/xpg4/bin/grep -E.
206 See grep(1). Portable applications should use /usr/xpg4/bin/grep -E.
207
208
209
210SunOS 5.11 24 Mar 2006 egrep(1)