home | O'Reilly's CD bookshelfs | FreeBSD | Linux | Cisco | Cisco Exam    

UNIX in a Nutshell: System V Edition

UNIX in a Nutshell: System V EditionSearch this book
Previous: Reference: edit Chapter 2
UNIX Commands
Next: Reference: env





] [


] [



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 expressions, as well as the extended set + , ? , | , and ( ) . Remember to enclose these characters in quotes. Regular expressions are described in Section 6. Exit status is 0 if any lines match, 1 if not, and 2 for errors. See also grep and fgrep . egrep typically runs faster than those.



Precede each line with its block number.


Print only a count of matched lines.

-e regexp

Use this if regexp begins with - .

-f file

Take expression from file .


List matched lines but not filenames (inverse of -l ).


Ignore uppercase and lowercase distinctions.


List filenames but not matched lines.


Print lines and their line numbers.


Silent mode: print only error messages, and return the exit status.


Print all lines that don't match regexp .


Search for occurrences of Victor or Victoria in file :

egrep 'Victor(ia)*' 


egrep '(Victor|Victoria)' 


Find and print strings such as old.doc1 or new.doc2 in files , and include their line numbers:

egrep -n '(old|new)/.doc?' 


Previous: Reference: edit UNIX in a Nutshell: System V Edition Next: Reference: env
Reference: edit Book Index Reference: env

The UNIX CD Bookshelf Navigation The UNIX CD BookshelfUNIX Power ToolsUNIX in a NutshellLearning the vi Editorsed & awkLearning the Korn ShellLearning the UNIX Operating System