Open System Services Shell and Utilities Reference Manual (G06.25+, H06.03+)
Table Of Contents
User Commands (d - f) ed(1)
f[file]Thef (filename) subcommand changes the default filename (the stored name of the last
file used) to file,iffile is given. If file is not given, the f subcommand prints the default
filename.
[address1,address2]g/pattern/subcommand_list
The g (global) subcommand first marks every line that matches the pattern. Then, for
each marked line, this subcommand sets the current line to that line and executes
subcommand_list. Place a single subcommand, or the first subcommand of a list, on the
same line with the g subcommand; place subsequent subcommands on separate lines.
Except for the last line, end each of these lines with a \ (backslash).
The subcommand_list can include the a, i, and c subcommands and their input. If the
last command in subcommand_list is normally the . (dot) that ends input mode, the .
(dot) is optional. If there is no subcommand_list, the ed subcommand displays the
current line. The subcommand_list cannot include the g, G, v, V,or! subcommands.
The g subcommand is similar to the v subcommand, which executes subcommand_list
for every line that does not contain a match for the pattern. Note that the g subcommand
defaults to the entire file, not to the current line.
[address1,address2]G/pattern/
The interactive G (Global) subcommand first marks every line that matches the pattern,
then displays the first marked line, sets the current line to that line, and waits for a sub-
command. G accepts any but the following ed subcommands: a, c, g, G, i, v, V, and !.
After the subcommand finishes, G displays the next marked line, and so on. G takes a
newline character as a null subcommand. & (ampersand) causes G to execute the previ-
ous subcommand again, if there is one. Note that subcommands executed within the G
subcommand can address and change any lines in the buffer. The G subcommand can
be terminated by pressing the Interrupt key sequence. Note that this subcommand
defaults to the entire file, not to the current line.
h The h (help) subcommand displays a short message that explains the reason for the most
recent ? notification. The current line number is unchanged.
H The H (Help) subcommand causes the ed command to enter a mode in which help mes-
sages (see the h subcommand) are displayed for all subsequent ? notifications. The H
subcommand toggles this mode, and it is initially set to "off." The current line number is
unchanged.
[address]i
text
. The i (insert) subcommand inserts text before the addressed line and sets the current line
to the last inserted line. Enter . (dot) to return to command mode. If no lines are
inserted, i sets the current line to the addressed line. This subcommand differs from the
a subcommand only in the placement of the input text. Address 0 is not legal for the i
subcommand.
[address1,address1+1]j
The j (join) subcommand joins contiguous lines by removing the intervening newline
characters. If given only one address, j does nothing. (For splitting lines, see the s sub-
command.) Note that lines that exceed the line length limit cannot be joined. If lines
are joined, the current line number is set to the address of the joined line; otherwise, the
current line number is unchanged.
[address]kx
The k (mark) subcommand marks the addressed line with name x, which must be a
527188-003 Hewlett-Packard Company 3−45