Skip to Main Content
Unix in a Nutshell, 4th Edition
book

Unix in a Nutshell, 4th Edition

by Arnold Robbins
October 2005
Intermediate to advanced content levelIntermediate to advanced
908 pages
46h 42m
English
O'Reilly Media, Inc.
Content preview from Unix in a Nutshell, 4th Edition

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.

-eregexp, --regexp=regexp

Use this if regexp begins with -.

-ffile, --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.

-Acount, --after-context=count

Print count lines of trailing context. ...

Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

Learning the Unix Operating System, 5th Edition

Learning the Unix Operating System, 5th Edition

John Strang, Grace Todino, Jerry Peek
UNIX and Linux System Administration Handbook, 5th Edition

UNIX and Linux System Administration Handbook, 5th Edition

Trent R. Hein, Evi Nemeth, Garth Snyder, Ben Whaley, Dan Mackin

Publisher Resources

ISBN: 0596100299Errata Page