Open System Services Shell and Utilities Reference Manual (G06.25+, H06.03+)
Table Of Contents
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 file into the buffer after the addressed line; r does not
delete the previous contents of the buffer. When entered without file, r reads the default
file, if any, into the buffer (see the e and f subcommands). r does not change the default
filename. Address 0 causes r to read a file in at the beginning of the buffer. After it
reads a file 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 file 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 filenames.
[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 specified replacement string. Without a
number n or the global indicator g, s replaces only the first 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 find 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 flags 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 first instance.
l Displays the final line in which a substitution was made in the format specified
for the l subcommand.
n Displays the final line in which a substitution was made in the format specified
for the n subcommand.
p Displays the final line in which a substitution was made in the format specified
for the p subcommand.
[address1,address2]taddress3
The t (transfer) subcommand inserts a copy of the addressed lines after address3. The t
527188-003 Hewlett-Packard Company 3−47