Open System Services Shell and Utilities Reference Manual (G06.25+, H06.03+)
Table Of Contents
ed(1) OSS Shell and Utilities Reference Manual
In most cases, only one ed subcommand can be entered on a line. The exceptions to this rule are
the n, p, and l subcommands, which can be added to any subcommand except e, E, f, q, Q, r, w,or
!.
The e, E, f, r, and w subcommands accept filenames as arguments. The ed command stores the
last filename used with a subcommand as a default filename. The next e, E, f, r,orw subcommand
given without a filename uses the default filename.
The ed command responds to an error condition with one of two messages: ? (question mark) or
?file. When the ed command receives an INT signal, it displays a ? and returns to command
mode. When ed reads a file, it discards NULL characters and all characters after the last newline
character.
Unless otherwise noted, all subcommands work by default on the current line; an address is
optional. If you specify an address, you do not type the brackets.
When used as an address, a . (dot) refers to the current line. When a . (dot) is shown in the first
position on an otherwise blank line, it terminates text mode and returns to command mode. text
denotes user input in text mode. Note that address need not be a number; it can be a regular
expression of the form /RE/,/RE/ or /RE/;/RE/.
[address]a
text
. The a (append) subcommand adds text to the buffer after the addressed line. Enter a .
(dot) to return to command mode. The a subcommand sets the current line to the last
inserted line or, if no lines were inserted, to the addressed line. Address 0 causes the a
subcommand to add text to the beginning of the buffer.
[address1,address2]c
text
. The c (change) subcommand deletes the addressed lines, then replaces them with new
input. Enter a . (dot) to return to command mode. The c subcommand sets the current
line to the last new line of input or, if there were none, to the first line that was not
deleted.
[address1,address2]d
The d (delete) subcommand removes the addressed lines from the buffer. The line after
the last line deleted becomes the current line. If the deleted lines were originally at the
end of the buffer, the new last line becomes the current line.
e file The e (edit) subcommand first deletes any contents from the buffer, then loads another
file into the buffer, sets the current line to the last line of the buffer, and displays the
number of bytes read in to the buffer. If the buffer was changed since its contents were
last saved (with the w subcommand), e displays ? before it clears the buffer.
The e subcommand stores file as the default filename to be used, if necessary, by subse-
quent e, E, r,orw subcommands. (See the f subcommand.)
When the ! (exclamation point) character replaces file, e takes the rest of the line as a
shell (sh) command and reads the command output. The e subcommand does not store
the name of the shell command as a default filename.
E file The E (Edit) subcommand works like the e subcommand, with one exception: E does
not check for changes made to the buffer since the last w subcommand.
3−44 Hewlett-Packard Company 527188-003