|
|
1.1 root 1:
2:
3: egrep Command egrep
4:
5:
6:
7:
8: Extended pattern search
9:
10: eeggrreepp [_o_p_t_i_o_n ...] [_p_a_t_t_e_r_n] [_f_i_l_e ...]
11:
12: egrep is an extended and faster version of grep. It searches
13: each file for occurrences of pattern (also called a regular
14: expression). If no file is specified, it searches the standard
15: input. Normally, it prints each line matching the pattern.
16:
17: ***** Wildcards *****
18:
19: The simplest patterns accepted by egrep are ordinary alphanumeric
20: strings. Like eedd, eeggrreepp can also process _p_a_t_t_e_r_n_s that include
21: the following wildcard characters:
22:
23: ^ Match beginning of line, unless it appears immediately after
24: `[' (see below).
25:
26: $ Match end of line.
27:
28: * Match zero or more repetitions of preceding character.
29:
30: . Match any character except newline.
31:
32: [_c_h_a_r_s]
33: Match any one of the enclosed chars. Ranges of letters or
34: digits may be indicated using `-'.
35:
36: [^_c_h_a_r_s]
37: Match any character except one of the enclosed chars. Ranges
38: of letters or digits may be indicated using `-'.
39:
40: \_c Disregard special meaning of character c.
41:
42: ***** Metacharacters *****
43:
44: In addition, egrep accepts the following additional metacharac-
45: ters:
46:
47: | Match the preceding pattern or the following pattern. For
48: example, the pattern cat|dog matches either cat or dog. A
49: newline within the pattern has the same meaning as `|'.
50:
51: + Match one or more occurrences of the immediately preceding
52: pattern element; it works like `*', except it matches at
53: least one occurrence instead of zero or more occurrences.
54:
55: ? Match zero or one occurrence of the preceding element of the
56: pattern.
57:
58: (...)
59: Parentheses may be used to group patterns. For example,
60: (Ivan)+ matches a sequence of one or more occurrences of the
61: four letters `I' `v' `a' or `n'.
62:
63:
64: COHERENT Lexicon Page 1
65:
66:
67:
68:
69: egrep Command egrep
70:
71:
72:
73:
74: Because the metacharacters `*', `?', `$', `(', `)', `[', `]', and
75: `|' are also special to the shell sshh, patterns that contain
76: those literal characters must be quoted by enclosing pattern
77: within single quotation marks.
78:
79: ***** Options *****
80:
81: The following lists the available options:
82:
83: -bb With each output line, print the block number in which the
84: line started (used to search file systems).
85:
86: -cc Print how many lines match, rather than the lines themselves.
87:
88: -ee The next argument is pattern (useful if the pattern starts
89: with `-').
90:
91: -ff The next argument is a file that contains a list of patterns
92: separated by newlines; there is no pattern argument.
93:
94: -hh When more than one file is specified, output lines are norm-
95: ally accompanied by the file name; -h suppresses this.
96:
97: -ll Print the name of each file that contains the string, rather
98: than the lines themselves. This is useful when you are con-
99: structing a batch file.
100:
101: -nn When a line is printed, also print its number within the
102: file.
103:
104: -ss Suppress all output, just return exit status.
105:
106: -vv Print a line only if the pattern is not found in the line.
107:
108: -yy Lower-case letters in the pattern match lower-case and upper-
109: case letters on the input lines. A letter escaped with `\'
110: in the pattern must be matched in exactly that case.
111:
112: ***** See Also *****
113:
114: awk, commands, ed, expr, grep, lex, sed
115:
116: ***** Diagnostics *****
117:
118: egrep returns an exit status of zero for success, one for no
119: matches, and two for error.
120:
121: ***** Notes *****
122:
123: Besides the difference in the range of patterns allowed, egrep
124: uses a deterministic finite automaton (DFA) for the search. It
125: builds the DFA dynamically, so it begins doing useful work im-
126: mediately. This means that egrep is is much faster than grep,
127: often by more than an order of magnitude, and is considerably
128:
129:
130: COHERENT Lexicon Page 2
131:
132:
133:
134:
135: egrep Command egrep
136:
137:
138:
139: faster than earlier pattern-searching commands, on almost any
140: length of file.
141:
142:
143:
144:
145:
146:
147:
148:
149:
150:
151:
152:
153:
154:
155:
156:
157:
158:
159:
160:
161:
162:
163:
164:
165:
166:
167:
168:
169:
170:
171:
172:
173:
174:
175:
176:
177:
178:
179:
180:
181:
182:
183:
184:
185:
186:
187:
188:
189:
190:
191:
192:
193:
194:
195:
196: COHERENT Lexicon Page 3
197:
198:
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.