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,--countPrint only a count of matched lines.
-eregexp,--regexp=regexpUse this if regexp begins with
-.-ffile,--file=fileTake expression from file. Multiple expressions may be provided, one per line, in which case any of them may match.
-i,--ignore-caseIgnore uppercase and lowercase distinctions.
-h,--no-filenameDo not print the names of matching files, just the matched lines.
-l,--files-with-matchesList filenames but not matched lines.
-n,--line-numberPrint lines and their line numbers.
-s,--no-messagesSilent mode: print only error messages, and return the exit status.
-
-v--invert-match Print all lines that don’t match regexp.
-x,--line-regexpSelect 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,--textTreat a binary file as text. Same as
--binary-files=text.-Acount,--after-context=countPrint count lines of trailing context. ...