ed.1 (2010 09)

e
ed(1) ed(1)
(.)kx The k
(mark) command marks the addressed line with the name x, which must be a
lower-case letter. The address
x then addresses this line. Upon completion, the new
current line remains unchanged from before.
(
.,.)l The l (list) command writes the addressed lines to standard output in a visually unambi-
guous form. Characters listed in the following table are written as the corresponding
escape sequence. Nonprintable characters not in the table are written as a three-digit
octal number (with a preceding backslash character) for each byte in the character (most
significant byte first).
Long lines are folded with the point of folding indicated by writing a backslash character
followed by a newline. The end of each line is marked with a
$.Anl (ell) command can
be appended to any command other than
e, E, f, q, Q, r, w,or!. The current line
number is set to the address of the last line written.
Escape ASCII Escape ASCII
Sequence Represents Name Sequence Represents Name
\\ backslash \ \r carriage return CR
\a alert BEL \t horizontal tab HT
\b backspace BS \v vertical tab VT
\f formfeed FF
(.,.)ma The m (move) command repositions the addressed lines after the line addressed by a.
Address 0 is legal for a, causing the addressed lines to be moved to the beginning of the
file. It is an error if address a falls within the range of moved lines; Upon completion,
the new current line is the last line moved.
(
.,.)n The n (number) command prints the addressed lines, preceding each line by its line
number and a tab character. Upon completion, the new current line is the last line
printed. The n command can be appended to any command other than e, f, r
,orw.
(
.,.)p The p (print) command prints the addressed lines. Upon completion, the new current
line is the last line printed. The p command may be appended to any other command
other than e, E, f, q, Q, r, w,or
!. For example, dp deletes the current line and prints
the new current line.
P The P (prompt) command causes ed to prompt with an asterisk (*) (or with string if the
-p option was specified in the command line) for all subsequent commands. The P
com-
mand alternately turns this mode on and off. It is initially on if the
-p
option was
specified; otherwise, off. The current line number is unchanged.
q The q (quit) command causes ed to exit. No automatic write of a file is done (but see
DIAGNOSTICS below).
Q The editor exits unconditionally without checking for changes in the buffer since the last
w command.
(
$)r file The r (read) command reads the specified file into the buffer after the addressed line. If
no file name is given, the remembered file name, if any, is used (see the e and f com-
mands). The remembered file name is not changed unless file is the very first file name
mentioned since ed was invoked. Address 0 is legal for r and places the contents of file
at the beginning of the buffer. If the read is successful, the number of characters read is
displayed. Upon completion, the new current line is the last line read into the buffer. If
the file name starts with !, the rest of the line is interpreted as a shell command whose
standard output is to be read. For example, $r !ls appends a listing of files in the
current directory to the end of the file being edited. A shell command is not remembered
as the current file name.
(
.,.)s/RE/replacement/flags
The s (substitute) command searches each addressed line for an occurrence of the
specified RE. In each line in which a match is found, all (nonoverlapped) matched
strings are replaced by replacement if the global replacement indicator g appears after
the command. If the global indicator does not appear, only the first occurrence of the
matched string is replaced. If a number n appears after the command, only the nth
occurrence of the matched string on each addressed line is replaced. It is an error for the
substitution to fail on all addressed lines. Any character other than space or newline can
be used instead of / to delimit the RE and replacement . Upon completion, the new
current line is the last line on which a substitution occurred. (Also see WARNINGS
4 Hewlett-Packard Company 4 HP-UX 11i Version 3: September 2010