Name
egrep
Synopsis
egrep [options
] [regexp
] [files
]
Search one or more files for lines that
match a regular expression regexp. egrep doesn’t support the metacharacters
\(
, \)
, \
n, \<
,
\>
, but does support the
other metacharacters, as well as the extended set +
, ?
,
|
, and ()
. Remember to enclose these characters
in quotes. Regular expressions are described in Chapter 7. Exit status is 0 if any
lines match, 1 if not, and 2 for errors. See also grep and fgrep.
Solaris /usr/bin/egrep
does not support \{
, or
\}
. Mac OS X and GNU/Linux use
GNU egrep.
Common Options
-c
,--count
Print only a count of matched lines.
-e
regexp
,--regexp=
regexp
Use this if regexp begins with
-
.-f
file
,--file=
file
Take expression from file. Multiple expressions may be provided, one per line, in which case any of them may match.
-i
,--ignore-case
Ignore uppercase and lowercase distinctions.
-h
,--no-filename
Do not print the names of matching files, just the matched lines.
-l
,--files-with-matches
List filenames but not matched lines.
-n
,--line-number
Print lines and their line numbers.
-s
,--no-messages
Silent mode: print only error messages, and return the exit status.
-
-v
--invert-match
Print all lines that don’t match regexp.
-x
,--line-regexp
Select only those matches that exactly match the whole line. (Only /usr/xpg4/bin/egrep on Solaris, not /usr/bin/egrep.)
GNU grep, egrep, and fgrep Options
-a
,--text
Treat a binary file as text. Same as
--binary-files=text
.-A
count
,--after-context=
count
Print count lines of trailing context. ...
Get Unix in a Nutshell, 4th Edition now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.