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

User Commands (d - f) ed(1)
Q The Q (Quit) subcommand exits the ed program without checking for changes to the
buffer since the last w subcommand (compare with the q subcommand).
[address]r file
The r (read) subcommand reads a le into the buffer after the addressed line; r does not
delete the previous contents of the buffer. When entered without le, r reads the default
le, if any, into the buffer (see the e and f subcommands). r does not change the default
lename. Address 0 causes r to read a le in at the beginning of the buffer. After it
reads a le successfully, r displays the number of bytes read into the buffer and sets the
current line to the last line read.
If ! (exclamation point) replaces le in a r subcommand, r takes the rest of the line as an
OSS shell (sh) command whose output is to be read. The r subcommand does not store
the names of shell commands as default lenames.
[address1,address2]s/pattern/replacement/flags
The s (substitute) subcommand searches each addressed line for a string that matches the
pattern and then replaces the string with the specied replacement string. Without a
number n or the global indicator g, s replaces only the rst matching string on each
addressed line. With n, s replaces the nth occurrence of pattern on the addressed line.
With the g indicator, s replaces every occurrence of the matching string on each
addressed line.
If s does not nd a match for the pattern, it returns the error message ?. Any character
except a space or a newline character can separate (delimit) the pattern and replacement
arguments. The s subcommand sets the current line to the last line changed.
An & (ampersand) in the replacement string is a special symbol that has the same value
as the pattern string. So, for example, the subcommand s/out/&ing/ has the same effect
as the subcommand s/out/outing/ and replaces out with outing on the current line. A
backslash before the ampersand (\&) removes this special meaning of & in replacement.
The % (percent sign), when used by itself as replacement, causes s to use the previous
replacement again. The % character does not have this special meaning if it is part of a
longer replacement or if it is preceded by a \ (backslash).
Lines can be split by substituting newline characters into them. In replacement, the
sequence \<Return> quotes the newline character (not displayed) and moves the cursor
to the next line for the remainder of the string.
The value of ags can be the following:
count Substitutes for the countth occurrence only of the regular expression that is
found on each addressed line.
g Substitutes globally for all nonoverlapping instances of the regular expression,
instead of just substituting for the rst instance.
l Displays the nal line in which a substitution was made in the format specied
for the l subcommand.
n Displays the nal line in which a substitution was made in the format specied
for the n subcommand.
p Displays the nal line in which a substitution was made in the format specied
for the p subcommand.
[address1,address2]taddress3
The t (transfer) subcommand inserts a copy of the addressed lines after address3. The t
527188-004 Hewlett-Packard Company 347