
754
This is the Title of the Book, eMatter Edition
Copyright © 2006 O’Reilly & Associates, Inc. All rights reserved.
Chapter 10
10
The sed Editor
The sed “stream editor” is one of the most prominent text-processing tools on
Unix and Linux. It is most often used for performing simple substitutions on data
streams going through pipelines, but sed scripts can be written to do much more.
This chapter presents the following topics:
• Conceptual overview of sed
• Command-line syntax
• Syntax of sed commands
• Group summary of sed commands
• Alphabetical summary of sed commands
The version of sed provided with Linux systems is the GNU version written by the
Free Software Foundation; its home page is http://www.gnu.org/software/sed/sed.html.
For more information on sed, see sed & awk (O’Reilly).
Conceptual Overview
The stream editor, sed, is a non-interactive editor. It interprets a script and
performs the actions in the script. sed is stream-oriented because, like many Unix
programs, input flows through the program and is directed to standard output.
For example, sort is stream-oriented; vi is not. sed’s input typically comes from a
file or pipe, but it can also be taken from the keyboard. Output goes to the screen
by default, but it can be captured in a file or sent through a pipe instead. GNU sed
can edit files that use multibyte character sets.
Typical Uses of sed
• Editing one or more files automatically. ...