ed(1)

ed(1)

When the character % is the only character in replacement, the replacement used in the most recent substitute command is used as the replacement in the current substitute com- mand. The % loses its special meaning when it is in a replacement string containing more than one character or when preceded by a \.

A line can be split by substituting a newline character into it. The newline in replacement must be escaped by preceding it by \. Such substitution cannot be done as part of a g or v command list.

The value of ¯ags is zero or more of:

nSubstitute for the nth occurrence only of the RE found on each addressed line.

gSubstitute for all nonoverlapped occurrences of the RE on each addressed line.

lWrite to standard output the ®nal line in which a substitution was made. The line is written in the format speci®ed for the l command.

nWrite to standard output the ®nal line in which a substitution was made. The line is written in the format speci®ed for the n command.

pWrite to standard output the ®nal line in which a substitution was made. The line is written in the format speci®ed for the p command.

(.,.)ta Same as m command, except that a copy of the addressed lines is placed after address a (which can be 0). Upon completion, the new current line is the last line of the copy.

uThe u (undo) command nulli®es the effect of the most recent command that modi®ed any- thing in the buffer, that is, the most recent a, c, d, g, G, i, j, m, r, s, t, v, or V com- mand. All changes made to the buffer by a g, G, v, or V global command are "undone" as a single change; if no changes were made by the global command (such as with g/RE/p), the u command has no effect. The current line number is set to the value it had immedi- ately before the command started.

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

The complement of the global command g in that the lines marked during the ®rst step are those that do not match the RE.

(1,$)V/RE/ The complement of the interactive global command G in that the lines marked during the ®rst step are those that do not match the RE.

(1,$)w file The w (write) command writes the addressed lines into the named ®le. If the ®le does not exist, it is created with mode 666 (readable and writable by everyone), unless the current umask setting dictates otherwise (see umask(1). The remembered ®le name is not changed unless ®le is the very ®rst ®le name encountered since ed was invoked. If no ®le name is given, the remembered ®le name, if any, is used (see the e and f commands). Upon completion, the current line address is unchanged. If the command is successful, the number of characters written is displayed.

If the ®le name starts with !, the rest of the line is interpreted as a shell command whose standard input is the addressed lines. Such a shell command is not remembered as the current ®le name.

XA key string is demanded from the standard input. Subsequent e, r, and w commands will encrypt and decrypt the text with this key, using the algorithm of crypt(1). An explicitly empty key turns off encryption.

($)=

The line number of the addressed line is displayed. The current line address is unchanged

 

by this command.

!shell-command

The remainder of the line after the ! is sent to the shell to be interpreted and executed as a command. Within the text of that command, the unescaped character % is replaced with the remembered ®le name. If a ! appears as the ®rst character of the shell command, it is replaced with the text of the previous shell command. Thus, !! repeats the last shell com- mand. If any expansion is performed, the expanded line is echoed. Upon completion, the current line address is unchanged.

(.+1) newline An address alone on a line causes the addressed line to be printed.

A newline alone is

equivalent to .+1p. This technique is useful for stepping forward through the buffer.

HP-UX Release 11i: December 2000

− 5 −

Section 1199

e