Open System Services Shell and Utilities Reference Manual (G06.28+, H06.05+)
User Commands (s) sed(1)
next input line. If read_file does not exist, it is treated as an empty file, causing no
error condition.
(2)s/pattern/replacement/flags
Substitutes the replacement string for the first occurrence of the pattern in the pattern
space. Any character that is entered after the s command can substitute for the / (slash)
separator, except \ (backslash) and the newline character. Within the regular expres-
sion and replacement string, the delimiter can appear as a literal if it is preceded by a \
(backslash).
An & (ampersand) appearing in the replacement string is replaced by the string match-
ing the RE. The special meaning of & in this context can be suppressed by preceding
it with a \ (backslash). The characters \n, where n is a digit, are replaced by the text
matched by the corresponding backreference expression.
A line can be split by substituting a newline character into it. You must escape the
newline character in the replacement string by preceding it with a \ backslash. A sub-
stitution is considered to have been performed even if the replacement string is identi-
cal to the string that it replaces.
You can add zero or more of the following flags:
n Substitutes replacement for the nth occurrence of pattern on each addressed
line, rather than for the first occurrence.
g Substitutes replacement for all nonoverlapping instances of pattern on each
addressed line, rather than for just the first one (or for the one specified by n).
p Writes the pattern space to standard output if a replacement was made.
w write_file
Writes the pattern space to write_file if a replacement was made. Appends
the pattern space to write_file.Ifwrite_file was not already created by a pre-
vious write by this sed script, sed creates it. Each write_file is created before
processing begins.
(2)t [label]
Branches to :label in the script file if any substitutions were made since the most recent
reading of an input line or execution of a t subcommand. If you do not specify label,
control transfers to the end of the script.
(2)w write_file
Appends the pattern space to write_file.
(2)x Exchanges the contents of the pattern space and the hold space.
(2)y/pattern1/pattern2/
Replaces all occurrences of characters in pattern1 with the corresponding characters
from pattern2. pattern1 and pattern2 must contain the same number of characters. The
delimiter itself can be used as a literal if it is preceded by a \ (backslash) character.
(2)!sed_command
Applies the specified sed subcommand only to lines not selected by this address or
addresses.
(2)!{subcommand ...
} Applies the specified subcommand list only to lines not selected by this address or
addresses. The { (left brace) can be preceded by spaces and can be followed by spaces
527188-007 Hewlett-Packard Company 8−5