|
Packit |
4e1bf9 |
Description
|
|
Packit |
4e1bf9 |
|
|
Packit |
4e1bf9 |
GNU ed is a line-oriented text editor. It is used to create, display,
|
|
Packit |
4e1bf9 |
modify and otherwise manipulate text files, both interactively and via
|
|
Packit |
4e1bf9 |
shell scripts. A restricted version of ed, red, can only edit files in
|
|
Packit |
4e1bf9 |
the current directory and cannot execute shell commands. Ed is the
|
|
Packit |
4e1bf9 |
"standard" text editor in the sense that it is the original editor for
|
|
Packit |
4e1bf9 |
Unix, and thus widely available. For most purposes, however, it is
|
|
Packit |
4e1bf9 |
superseded by full-screen editors such as GNU Emacs or GNU Moe.
|
|
Packit |
4e1bf9 |
|
|
Packit |
4e1bf9 |
Extensions to and deviations from the POSIX standard are described below.
|
|
Packit |
4e1bf9 |
|
|
Packit |
4e1bf9 |
See the file INSTALL for compilation and installation instructions.
|
|
Packit |
4e1bf9 |
|
|
Packit |
4e1bf9 |
Try "ed --help" for usage instructions.
|
|
Packit |
4e1bf9 |
|
|
Packit |
4e1bf9 |
Report bugs to bug-ed@gnu.org
|
|
Packit |
4e1bf9 |
|
|
Packit |
4e1bf9 |
Ed home page: http://www.gnu.org/software/ed/ed.html
|
|
Packit |
4e1bf9 |
|
|
Packit |
4e1bf9 |
For a description of the ed algorithm, see Kernighan and Plauger's book
|
|
Packit |
4e1bf9 |
"Software Tools in Pascal", Addison-Wesley, 1981.
|
|
Packit |
4e1bf9 |
|
|
Packit |
4e1bf9 |
|
|
Packit |
4e1bf9 |
GNU ed(1) is not strictly POSIX compliant, as described in the
|
|
Packit |
4e1bf9 |
POSIX 1003.1-2004 document. The following is a summary of omissions
|
|
Packit |
4e1bf9 |
and extensions to, and deviations from, the POSIX standard.
|
|
Packit |
4e1bf9 |
|
|
Packit |
4e1bf9 |
OMISSIONS
|
|
Packit |
4e1bf9 |
---------
|
|
Packit |
4e1bf9 |
* Locale(3) is not supported.
|
|
Packit |
4e1bf9 |
|
|
Packit |
4e1bf9 |
EXTENSIONS
|
|
Packit |
4e1bf9 |
----------
|
|
Packit |
4e1bf9 |
* Though GNU ed is not a stream editor, it can be used to edit binary files.
|
|
Packit |
4e1bf9 |
To assist in binary editing, when a file containing at least one ASCII
|
|
Packit |
4e1bf9 |
NUL character is written, a newline is not appended if it did not
|
|
Packit |
4e1bf9 |
already contain one upon reading. In particular, reading /dev/null
|
|
Packit |
4e1bf9 |
prior to writing prevents appending a newline to a binary file.
|
|
Packit |
4e1bf9 |
|
|
Packit |
4e1bf9 |
For example, to create a file with GNU ed containing a single NUL character:
|
|
Packit |
4e1bf9 |
$ ed file
|
|
Packit |
4e1bf9 |
a
|
|
Packit |
4e1bf9 |
^@
|
|
Packit |
4e1bf9 |
.
|
|
Packit |
4e1bf9 |
r /dev/null
|
|
Packit |
4e1bf9 |
wq
|
|
Packit |
4e1bf9 |
|
|
Packit |
4e1bf9 |
Similarly, to remove a newline from the end of binary 'file':
|
|
Packit |
4e1bf9 |
$ ed file
|
|
Packit |
4e1bf9 |
r /dev/null
|
|
Packit |
4e1bf9 |
wq
|
|
Packit |
4e1bf9 |
|
|
Packit |
4e1bf9 |
* BSD commands have been implemented wherever they do not conflict with
|
|
Packit |
4e1bf9 |
the POSIX standard. The BSD-ism's included are:
|
|
Packit |
4e1bf9 |
* 's' (i.e., s[1-9rgp]*) to repeat a previous substitution,
|
|
Packit |
4e1bf9 |
* 'W' for appending text to an existing file,
|
|
Packit |
4e1bf9 |
* 'wq' for exiting after a write, and
|
|
Packit |
4e1bf9 |
* 'z' for scrolling through the buffer.
|
|
Packit |
4e1bf9 |
|
|
Packit |
4e1bf9 |
* The POSIX interactive global commands 'G' and 'V' are extended to
|
|
Packit |
4e1bf9 |
support multiple commands, including 'a', 'i' and 'c'. The command
|
|
Packit |
4e1bf9 |
format is the same as for the global commands 'g' and 'v', i.e., one
|
|
Packit |
4e1bf9 |
command per line with each line, except for the last, ending in a
|
|
Packit |
4e1bf9 |
backslash (\).
|
|
Packit |
4e1bf9 |
|
|
Packit |
4e1bf9 |
* The file commands 'E', 'e', 'r', 'W' and 'w' process a <file>
|
|
Packit |
4e1bf9 |
argument for backslash escapes; i.e., any character preceded by a
|
|
Packit |
4e1bf9 |
backslash is interpreted literally. If the first character of a
|
|
Packit |
4e1bf9 |
<file> argument is a bang (!), then the rest of the line is
|
|
Packit |
4e1bf9 |
interpreted as a shell command, and no escape processing is
|
|
Packit |
4e1bf9 |
performed by GNU ed.
|
|
Packit |
4e1bf9 |
|
|
Packit |
4e1bf9 |
* For SunOS ed(1) compatibility, GNU ed runs in restricted mode if invoked
|
|
Packit |
4e1bf9 |
as red. This limits editing of files in the local directory only and
|
|
Packit |
4e1bf9 |
prohibits shell commands.
|
|
Packit |
4e1bf9 |
|
|
Packit |
4e1bf9 |
DEVIATIONS
|
|
Packit |
4e1bf9 |
----------
|
|
Packit |
4e1bf9 |
* To support the BSD 's' command (see EXTENSIONS above), substitution
|
|
Packit |
4e1bf9 |
patterns cannot be delimited by the digits '1' to '9' or by the
|
|
Packit |
4e1bf9 |
characters 'r', 'g' and 'p'. In contrast, POSIX specifies that any
|
|
Packit |
4e1bf9 |
character except space and newline can be used as a delimiter.
|
|
Packit |
4e1bf9 |
|
|
Packit |
4e1bf9 |
* Since the behavior of 'u' (undo) within a 'g' (global) command list is
|
|
Packit |
4e1bf9 |
not specified by POSIX, GNU ed follows the behavior of the SunOS ed:
|
|
Packit |
4e1bf9 |
undo forces a global command list to be executed only once, rather than
|
|
Packit |
4e1bf9 |
for each line matching a global pattern. In addtion, each instance of
|
|
Packit |
4e1bf9 |
'u' within a global command undoes all previous commands (including
|
|
Packit |
4e1bf9 |
undo's) in the command list. This seems the best way, since the
|
|
Packit |
4e1bf9 |
alternatives are either too complicated to implement or too confusing
|
|
Packit |
4e1bf9 |
to use.
|
|
Packit |
4e1bf9 |
|
|
Packit |
4e1bf9 |
* The 'm' (move) command within a 'g' command list also follows the SunOS
|
|
Packit |
4e1bf9 |
ed implementation: any moved lines are removed from the global command's
|
|
Packit |
4e1bf9 |
'active' list.
|
|
Packit |
4e1bf9 |
|
|
Packit |
4e1bf9 |
* For backwards compatibility, errors in piped scripts do not force ed
|
|
Packit |
4e1bf9 |
to exit. POSIX only specifies ed's response for input via regular
|
|
Packit |
4e1bf9 |
files (including here documents) or tty's.
|
|
Packit |
4e1bf9 |
|
|
Packit |
4e1bf9 |
|
|
Packit |
4e1bf9 |
TESTSUITE
|
|
Packit |
4e1bf9 |
---------
|
|
Packit |
4e1bf9 |
The files in the 'testsuite' directory with extensions '.ed', '.r', and
|
|
Packit |
4e1bf9 |
'.err' are used for testing ed. To run the tests, configure the package
|
|
Packit |
4e1bf9 |
and type 'make check' from the build directory. The tests do not
|
|
Packit |
4e1bf9 |
exhaustively verify POSIX compliance nor do they verify correct 8-bit or
|
|
Packit |
4e1bf9 |
long line support.
|
|
Packit |
4e1bf9 |
|
|
Packit |
4e1bf9 |
The test file extensions have the following meanings:
|
|
Packit |
4e1bf9 |
.ed Ed script - a list of ed commands.
|
|
Packit |
4e1bf9 |
.r Result - the expected output after processing data via an ed
|
|
Packit |
4e1bf9 |
script.
|
|
Packit |
4e1bf9 |
.err Error - invalid ed commands that should generate an error.
|
|
Packit |
4e1bf9 |
|
|
Packit |
4e1bf9 |
The output of the .ed scripts is written to files with .o extension and
|
|
Packit |
4e1bf9 |
compared with their corresponding .r result files. The .err scripts
|
|
Packit |
4e1bf9 |
should exit with non-zero status without altering the contents of the
|
|
Packit |
4e1bf9 |
buffer.
|
|
Packit |
4e1bf9 |
|
|
Packit |
4e1bf9 |
If any test fails, the error messages look like:
|
|
Packit |
4e1bf9 |
|
|
Packit |
4e1bf9 |
*** The script u.ed exited abnormally ***
|
|
Packit |
4e1bf9 |
or:
|
|
Packit |
4e1bf9 |
*** Output u.o of script u.ed is incorrect ***
|
|
Packit |
4e1bf9 |
|
|
Packit |
4e1bf9 |
|
|
Packit |
4e1bf9 |
Copyright (C) 1993, 1994 Andrew Moore
|
|
Packit |
4e1bf9 |
Copyright (C) 2006-2017 Antonio Diaz Diaz.
|
|
Packit |
4e1bf9 |
|
|
Packit |
4e1bf9 |
This file is free documentation: you have unlimited permission to copy,
|
|
Packit |
4e1bf9 |
distribute and modify it.
|
|
Packit |
4e1bf9 |
|
|
Packit |
4e1bf9 |
The file Makefile.in is a data file used by configure to produce the
|
|
Packit |
4e1bf9 |
Makefile. It has the same copyright owner and permissions that configure
|
|
Packit |
4e1bf9 |
itself.
|