
764
|
Chapter 10: The sed Editor
This is the Title of the Book, eMatter Edition
Copyright © 2006 O’Reilly & Associates, Inc. All rights reserved.
Example
/Item 1/i\
The five items are listed below:
l
[address1[,address2]]l
[address1[,address2]]l [len] {G}
List the contents of the pattern space, showing nonprinting charac-
ters as ASCII codes. Long lines are wrapped. With GNU sed, len is
the character position at which to wrap long lines. A value of 0
means to never break lines.
n
[address1[,address2]]n
Read the next line of input into pattern space. The current line is
sent to standard output, and the next line becomes the current line.
Control passes to the command following n instead of resuming at
the top of the script.
Example
In DocBook/XML, titles follow section tags. Suppose you are using
a convention where each opening section tag is on a line by itself,
with the title on the following line. To print all the section titles,
invoke this script with sed -n:
/<sect[1-4]/{
n
p
}
N
[address1[,address2]]N
Append the next input line to contents of pattern space; the new
line is separated from the previous contents of the pattern space by
a newline. (This command is designed to allow pattern matches
across two lines.) By using \n to match the embedded newline, you
can match patterns across multiple lines. See the Example under D.
Examples
Like the Example in n, but print the section tag line as well as
header title: ...