sed.1 (2010 09)
s
sed(1) sed(1)
command, and can be used to protect initial blanks and tabs against the stripping that
is done on every script line.
rfile Must terminate the command line, and must be preceded by exactly one blank.
wfile Must terminate the command line, and must be preceded by exactly one blank. Each
wfile is created before processing begins. There can be at most 10 distinct wfile argu-
ments.
sed recognizes the following functions:
(1)
a\
text Append. Place text on the output before reading next input line.
(2)
b label Branch to the : command bearing label .Ifnolabel is specified, branch to the end of the
script.
(2)
c\
text Change. Delete the pattern space. With 0 or 1 address or at the end of a 2-address range,
place text on the output. Start the next cycle.
(2)
d Delete pattern space and start the next cycle.
(2)
D Delete initial segment of pattern space through first new-line and start the next cycle.
(2)
g Replace contents of the pattern space with contents of the hold space.
(2)
G Append contents of hold space to the pattern space.
(2)
h Replace contents of the hold space with contents of the pattern space.
(2)
H Append the contents of the pattern space to the hold space.
(1)
i\
text Insert. Place text on the standard output.
(2)
l List the pattern space on the standard output in an unambiguous form. Non-printing char-
acters are spelled in three-digit octal number format (with a preceding backslash), and long
lines are folded.
(2)
n Copy the pattern space to the standard output if the default output has not been suppressed
(by the -n option on the command line or the #n command in the script file). Replace the
pattern space with the next line of input.
(2)
N Append the next line of input to the pattern space with an embedded new-line. (The current
line number changes.)
(2)
p Print. Copy the pattern space to the standard output.
(2)
P Copy the initial segment of the pattern space through the first new-line to the standard out-
put.
(1)
q Quit. Branch to the end of the script. Do not start a new cycle.
(1)
r rfile Read contents of rfile and place on output before reading the next input line.
(2)
s/regular expression/replacement/flags
Substitute replacement string for instances of regular expression in the pattern space. Any
character can be used instead of /. For a fuller description see ed(1). flags is zero or more
of:
nn= 1-2048 (
LINE_MAX). Substitute for just the nth occurrence of regular
expression in the pattern space.
g Global. Substitute for all non-overlapping instances of regular expression
rather than just the first one.
p Print the pattern space if a replacement was made and the default output
has been suppressed (by the -n option on the command line or the #n com-
mand in the script file).
Under the
UNIX Standard environment (see standards (5)), the pattern
space is printed twice, if the -n option is not specified on the command line.
w wfile Write. Append the pattern space to wfile if a replacement was made.
2 Hewlett-Packard Company − 2 − HP-UX 11i Version 3: September 2010