Chapter 1. sed & awk Pocket Reference


This pocket reference is a companion volume to O’Reilly’s sed & awk, Second Edition, by Dale Dougherty and Arnold Robbins, and to Effective awk Programming, Third Edition, by Arnold Robbins. It presents a concise summary of regular expressions and pattern matching, and summaries of sed, awk, and gawk (GNU awk).

Conventions Used in This Book

This pocket reference follows certain typographic conventions, outlined here:

Constant Width

Used for code examples, commands, directory names, and options.

Constant Width Italic

Used in syntax and command summaries to show replaceable text; this text should be replaced with user-supplied values.

Constant Width Bold

Used in code examples to show commands or other text that should be typed literally by the user.


Used to show generic arguments and options; these should be replaced with user-supplied values. Italic is also used to highlight comments in examples, to introduce new terms, and to indicate filenames.


Used in some examples as the Bourne shell or Korn shell prompt.

[ ]

Surround optional elements in a description of syntax. (The brackets themselves should never be typed.)

Matching Text

A number of Unix text-processing utilities let you search for, and in some cases change, text patterns rather than fixed strings. These utilities include the editing programs ed, ex, vi, and sed, the awk programming language, and the commands grep and egrep. Text patterns (formally called regular ...

Get sed and awk Pocket Reference, 2nd Edition now with the O’Reilly learning platform.

O’Reilly members experience live online training, plus books, videos, and digital content from nearly 200 publishers.