ed.1 (2010 09)

e
ed(1) ed(1)
!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 file name. If a
! appears as the first character of the shell com-
mand, it is replaced with the text of the previous shell command. Thus,
!! repeats the
last shell command. 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.
If an interrupt signal (ASCII DEL or BREAK) is sent,
ed prints a ? and returns to its command level.
The following size limitations apply: 256 characters per global command list, 64 characters per file name,
and 32 MB characters in the buffer. The limit on the number of lines depends on the amount of user
memory: each line takes 1 word.
EXTERNAL INFLUENCES
For information about the UNIX standard environment, see standards (5).
Environment Variables
SHELL determines the preferred command-line interpreter for use in all !-style commands. If this vari-
able is null or not set, the POSIX shell, /usr/bin/sh, is used (see sh-posix (1)).
When set,
TMPDIR specifies a directory to be used for temporary files, overriding the default directory,
/tmp.
LANG provides a default value for internationalization variables that are unset or null. If
LANG is unset
or null, the default value is "C" (see lang (5)). If any internationalization variable contains an invalid set-
ting, all internationalization variables default to "C". See environ (5).
If
LC_ALL is set to a nonempty string value, it overrides the values of all the other internationalization
variables, including LANG.
LC_CTYPE determines the interpretation of text as single- and/or multibyte characters, the classification
of characters as printable, and the characters matched by character class expressions in regular expres-
sions.
LC_MESSAGES determines the locale that should be used to affect the format and contents of diagnostic
messages written to standard error and informative messages written to standard output.
NLSPATH determines the location of message catalogues for the processing of LC_MESSAGES.
International Code Set Support
Single- and multibyte character code sets are supported.
DIAGNOSTICS
? Command error. Use h or H to get a detailed explanation.
?file Inaccessible file. Use h or H to get a detailed explanation.
If changes have been made in the buffer since the last
w command that wrote the entire buffer, ed warns
you if you attempt to destroy the buffer with an e or q command. ed displays ? or warning:
expecting ‘w’, then continues normal editing unless you enter a second e or q command, in which
case the second command is executed. The -s or - command-line option inhibits this feature.
EXAMPLES
Make a simple substitution in
file-1 from a shell script, changing the first occurrence of abc in any
line to xyz, and save the changes in file-2.
cat - << EOF | ed -s file-1
1,$ s/abc/xyz/
w file-2
q
EOF
Note that, if a command fails, the editor exits immediately.
6 Hewlett-Packard Company 6 HP-UX 11i Version 3: September 2010