Open System Services Shell and Utilities Reference Manual (G06.27+, H06.04+)

User Commands (s) sed(1)
character, which does not terminate the regular expression (RE). For example, in the
context address \xabc\xdefx, the second x stands for itself, so that the RE is abcxdef.
The sequence \n matches a newline character in the pattern space, except the terminating
new line. A literal newline character must not be used in the regular expression of a con-
text address or in the s (substitute) subcommand.
A . (dot) matches any character except a terminating newline character. That is, unlike
grep, which cannot match a newline character in the middle of a line, sed can match a
newline character in the pattern space.
Certain commands allow you to specify one line or a range of lines to which the command
applies. These commands are called addressed commands. The following rules apply to
addressed commands:
A command line with no address selects every line.
A command line with one address, expressed in context form, selects each line that
matches the address.
A command line with two addresses separated by a , (comma) or ; (semicolon) selects
the entire range from the rst line that matches the rst address through the next line that
matches the second. (If the second address is a number less than or equal to the line
number rst selected, only one line is selected.) Thereafter, the process is repeated,
looking again for the rst address.
SUBCOMMANDS
Backslashes in text are treated like backslashes in the replacement string of an s command and
can be used to protect initial spaces and tabs against the stripping that is done on every script
line.
The text argument accompanying the a\, c\, and i\ commands can continue onto more than one
line, provided all lines but the last end with a \ (backslash) to quote the newline character.
The read_le and write_le arguments must end the command line and must be preceded by
exactly one space. Each write_le is created before processing begins, up to a maximum of 10
les.
The sed command can process up to 99 commands in a le.
In the following list of subcommands, the maximum number of permissible addresses for each
subcommand is indicated in parentheses. The sed script subcommands are as follows:
(2){subcommand ...
} Groups subcommands enclosed in {}(braces). The { (left brace) can be preceded by
spaces and can be followed by spaces or tabs. The list of subcommands must be
separated by newline characters. The subcommands can also be preceded by spaces or
tabs. The terminating } (right brace) must be preceded by a newline character and then
zero or more spaces.
(1) a\
text Places text in the output le before reading the next input line, whether by executing N
or by beginning a new cycle.
(2)b [label]
Branches to the : command bearing the label.Iflabel is empty, it branches to the end
of the script.
527188-004 Hewlett-Packard Company 83