ed(1)

ed(1)

(.,.)c

The c (change) command deletes the addressed lines then accepts input text to replace the

text

deleted lines. Upon completion, the new current line is the last line in text or, if no text

.

was provided, at the ®rst line after the deleted line or lines.

(.,.)d

The d (delete) command deletes the addressed lines from the buffer. Upon completion, the

 

new current line is the ®rst line following the deleted text, or the last line in the ®le if the

 

deleted line or lines were at the end of the buffer.

e file

The e (edit) command deletes the entire contents of the buffer, then reads in the named

 

®le. Upon completion, the new current line is the last line in the buffer. If no ®le name is

 

given, the remembered ®le name, if any, is used (see the f command). The number of

 

characters read is displayed, and ®le is remembered for possible use as a default ®le name

 

in subsequent e, r, or w commands.

 

If the ®le name starts with !, the rest of the line is interpreted as a shell command whose

 

standard output is to be read. Such a shell command is not remembered as the current ®le

 

name.

 

Also see DIAGNOSTICS below.

E file

The E (forced edit) command is identical to e except that no check is made to ensure that

 

the current buffer has not been altered since the last w command.

f file

If ®le is speci®ed, the f (®le name) command changes the remembered ®le name to ®le.

 

Otherwise, it prints the remembered ®le name.

(1,$)g/RE/command-list

The g (global) command ®rst marks every line that matches the given RE. Then, for every such line, the given command-listis executed with the current line initially set to that line. A single command or the ®rst of a list of commands appears on the same line as the global command. All lines of a multiple-line list except the last line must end with a backslash (\). a, i, and c commands and associated input are permitted. The . that normally terminates input mode can be omitted if it would be the last line of the command-list. An empty command-listis equivalent to the p command. The g, G, v, and V commands are not permitted in the command-list. (Also see WARNINGS below.)

(1,$)G/RE/ The interactive G (Global) command ®rst marks every line that matches the given RE. Then, for every such line, the line is printed, then the current line is changed to that line and one command (other than a, c, i, g, G, v, or V) can be input and executed. After executing that command, the next marked line is printed, and so on. A newline character acts as a null command, and an & causes the re-execution of the most recent command executed within the current invocation of G. Note that the commands input as part of the execution of the G command may address and affect any lines in the buffer. The G command can be terminated by an interrupt signal (ASCII DEL or BREAK).

hThe h (help) command gives a short error message explaining the reason for the most recent ? diagnostic.

HThe H (Help) command causes ed to enter a mode in which error messages are printed for all subsequent ? diagnostics. It also explains the previous ? if there was one. The H com- mand alternately turns this mode on and off. Initially, it is off.

(.)i

The i (insert) command inserts the given text before the addressed line. Upon completion,

text

the current line is the last inserted line, or, if there were none, the addressed line. This

.

command differs from the a command only in the placement of the input text. Address 0 is

 

not legal for this command.

 

 

(.,.+1)j

The j (join) command joins contiguous lines by removing the appropriate newline charac-

 

ters. If exactly one address is given, this command does nothing.

 

(.)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 unambigu-

 

ous 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

 

signi®cant byte ®rst).

 

 

HP-UX Release 11i: December 2000

− 3 −

Section 1197

e