O'Reilly logo

Mac OS X Tiger in a Nutshell by Jason McIntosh, Chuck Toporek, Chris Stone, Andy Lester

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Name

egrep

Synopsis

egrep [options] [regexp] [files]

Searches one or more files for lines that match an extended regular expression regexp. egrep doesn't support the regular expressions \ (, \), \ 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 Chapter 6. Exit status is 0 if any lines match, 1 if none match, and 2 for errors.

See grep for the list of available options. Also see fgrep . egrep typically runs faster than those commands.

Examples

Search for occurrences of Victor or Victoria in file:

$ egrep 'Victor(ia)*'
                     file
$ egrep '(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

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required