Skip to Content
Linux in a Nutshell, 6th Edition
book

Linux in a Nutshell, 6th Edition

by Ellen Siever, Stephen Figgins, Robert Love, Arnold Robbins
September 2009
Beginner
942 pages
85h 34m
English
O'Reilly Media, Inc.
Content preview from Linux in a Nutshell, 6th Edition

Name

grep

Synopsis

grep [options] pattern [files]

Search one or more files for lines that match a regular expression pattern. Regular expressions are described in Chapter 7. Exit status is 0 if any lines match, 1 if none match, and 2 for errors. See also egrep and fgrep.

Options

-a, --text

Don’t suppress output lines with binary data; treat as text.

-A num, --after-context=num

Print num lines of text that occur after the matching line.

-b, --byte-offset

Print the byte offset within the input file before each line of output.

-B num, --before-context=num

Print num lines of text that occur before the matching line.

-c, --count

Print only a count of matched lines. With -v or --revert-match, count nonmatching lines.

-C[num], --context[=num], -num

Print num lines of leading and trailing context. Default context is 2 lines.

-d action, --directories=action

Define an action for processing directories. Possible actions are:

read

Read directories like ordinary files (default).

skip

Skip directories.

recurse

Recursively read all files under each directory. Same as -r.

-D action, --directories=action

Define an action for processing an input file that is a device, FIFO, or socket. Possible actions are read (default) and skip, as in -d.

-e pattern, --regexp=pattern

Search for pattern. Same as specifying a pattern as an argument, but useful in protecting patterns beginning with -.

-E, -extended-regexp

Act like egrep, recognizing extended regular expressions such as (UN|POS)IX to find UNIX and POSIX.

-f file, --file=file

Take ...

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

Unix in a Nutshell, 4th Edition

Unix in a Nutshell, 4th Edition

Arnold Robbins
Linux Under the Hood

Linux Under the Hood

Sander van Vugt
Linux Kernel in a Nutshell

Linux Kernel in a Nutshell

Greg Kroah-Hartman

Publisher Resources

ISBN: 9780596806088Errata Page