egrep [options] [regexp] [files]Search one or more files for lines that match a regular expression regexp. egrep doesn't support the metacharacters \(, \), \n, \<, \>, \{, or \}, 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 6, Pattern Matching. Exit status is 0 if any lines match, 1 if not, and 2 for errors. See also grep and fgrep.
-bPrecede each line with its block number. (Not terribly useful.)
-cPrint only a count of matched lines.
-e regexpUse this if regexp begins with -.
-f fileTake expression from file.
-hList matched lines but not filenames (inverse of -l).
-iIgnore uppercase and lowercase distinctions.
-lList filenames but not matched lines.
-nPrint lines and their line numbers.
-sSilent mode: print only error messages, and return the exit status. Not on SVR4, but common on most commercial Unix systems.
-vPrint all lines that don't match regexp.
Search for occurrences of Victor or Victoria in file:
egrep 'Victor(ia)?'fileegrep '(Victor|Victoria)'file
Find and print strings such as old.doc1 or new.doc2 in files, and include their line numbers:
egrep -n '(old|new)\.doc?'files