Skip to Content
Mac OS X in a Nutshell
book

Mac OS X in a Nutshell

by Jason McIntosh, Chuck Toporek, Chris Stone
January 2003
Intermediate to advanced
832 pages
32h 40m
English
O'Reilly Media, Inc.
Content preview from Mac OS X in a Nutshell

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 20. 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.

--binary-files= type

Treat binary files as specified. By default, grep treats binary files as such (type is binary). If a matching string is found within a binary file, grep reports only that the file matches; nothing is printed for nonmatching binary files. If type is without-match, grep assumes binary files don’t match and skips them altogether. Same as -I. Using a type of text causes grep to treat binary files as text and print all matched lines. Same as -a.

-c, --count

Print only a count of matched lines. With the -v or --invert-match option, 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 ...

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

Mac OS X Internals: A Systems Approach

Mac OS X Internals: A Systems Approach

Amit Singh
C++ In a Nutshell

C++ In a Nutshell

Ray Lischner
Linux Shell Scripting Cookbook - Third Edition

Linux Shell Scripting Cookbook - Third Edition

Clif Flynt, Sarath Lakshman, Shantanu Tushar
Optimized C++

Optimized C++

Kurt Guntheroth

Publisher Resources

ISBN: 0596003706Supplemental ContentCatalog PageErrata