ed: Invoking ed
3 Invoking ed
*************
The format for running 'ed' is:
ed [OPTIONS] [[+LINE] FILE]
red [OPTIONS] [[+LINE] FILE]
ed [OPTIONS] [[+LINE] '!COMMAND [ARGUMENTS]']
FILE specifies the name of a file to read. If FILE is prefixed with a
bang (!), then it is interpreted as a shell command. In this case, what is
read is the standard output of FILE executed via 'sh'. To read a file whose
name begins with a bang (or a hyphen), prefix the name with './'. The
default filename is set to FILE only if it is not prefixed with a bang.
The file name may be preceded by '+LINE' to set the current line to the
line number specified. If LINE exceeds the number of lines in the file, the
current line is set to the last line.
The file name may be preceded by '+/RE' to set the current line to the
first line matching the regular expression RE, or by '+?RE' to set the
current line to the last line matching RE. If RE does not match any line,
ed fails immediately with exit status 1 unless the option '-l' is specified
and standard input is not a regular file.
'ed' supports the following options: ⇒Argument syntax
(arg_parser)Argument syntax.
'-h'
'--help'
Print an informative help message describing the options and exit.
'-V'
'--version'
Print the version number of 'ed' on the standard output and exit. This
version number should be included in all bug reports.
'-E'
'--extended-regexp'
Use extended regular expressions instead of the basic regular
expressions mandated by POSIX.
'-G'
'--traditional'
Forces backwards compatibility. This affects the behavior of the 'ed'
commands 'G', 'V', 'f', 'l', 'm', 't', and '!!'. If the default
behavior of these commands does not seem familiar, then try invoking
'ed' with this switch.
'-l'
'--loose-exit-status'
Don't exit with bad status if a command happens to "fail" (for example
if a substitution command finds nothing to replace). This can be useful
when 'ed' is invoked as the editor for crontab.
'-p STRING'
'--prompt=STRING'
Specifies a command prompt string and turns prompting on. Showing the
prompt string may be toggled on and off with the 'P' command.
'-q'
'--quiet'
'--silent'
Suppress diagnostic messages written to standard error.
'-r'
'--restricted'
Run in restricted mode. This mode disables editing of files out of the
current directory and execution of shell commands.
'-s'
'--script'
Suppress the printing of byte counts by 'e', 'E', 'r', and 'w'
commands, and the '!' prompt after a '!' command. This option does not
suppress diagnostic messages written to standard error (see '-q'
above). '-s' may be useful if 'ed''s standard input is from a script.
'-v'
'--verbose'
Turn help mode on; print a help message explaining the reason for each
'?' notification. This may be toggled on and off with the 'H' command.
Use this option to aid in debugging ed scripts.
'--strip-trailing-cr'
Strip the carriage returns at the end of text lines in DOS files. CRs
are removed only from the CR/LF (carriage return/line feed) pair
ending the line. CRs at other positions in the line, including a CR
finishing an unterminated line, are not removed. The CRs are not
restored when saving the buffer to a file.
'--unsafe-names'
'ed' rejects file names containing control characters 1 to 31 unless
they are allowed with this option.
Exit status: 0 for a normal exit, 1 for environmental problems (invalid
command-line options, memory exhausted, command failed, etc), 2 for
problems with the input file (file not found, buffer modified, I/O errors),
3 for an internal consistency error (e.g., bug) which caused ed to panic.