3 GNU ed is a line-oriented text editor. It is used to create, display,
4 modify and otherwise manipulate text files, both interactively and via
5 shell scripts. A restricted version of ed, red, can only edit files in
6 the current directory and cannot execute shell commands. Ed is the
7 "standard" text editor in the sense that it is the original editor for
8 Unix, and thus widely available. For most purposes, however, it is
9 superseded by full-screen editors such as GNU Emacs or GNU Moe.
11 Extensions to and deviations from the POSIX standard are described below.
13 See the file INSTALL for compilation and installation instructions.
15 Try "ed --help" for usage instructions.
17 Report bugs to bug-ed@gnu.org
19 Ed home page: http://www.gnu.org/software/ed/ed.html
21 For a description of the ed algorithm, see Kernighan and Plauger's book
22 "Software Tools in Pascal", Addison-Wesley, 1981.
25 GNU ed(1) is not strictly POSIX compliant, as described in the
26 POSIX 1003.1-2004 document. The following is a summary of omissions
27 and extensions to, and deviations from, the POSIX standard.
31 * Locale(3) is not supported.
35 * Though GNU ed is not a stream editor, it can be used to edit binary files.
36 To assist in binary editing, when a file containing at least one ASCII
37 NUL character is written, a newline is not appended if it did not
38 already contain one upon reading. In particular, reading /dev/null
39 prior to writing prevents appending a newline to a binary file.
41 For example, to create a file with GNU ed containing a single NUL character:
49 Similarly, to remove a newline from the end of binary 'file':
54 * BSD commands have been implemented wherever they do not conflict with
55 the POSIX standard. The BSD-ism's included are:
56 * 's' (i.e., s[n][rgp]*) to repeat a previous substitution,
57 * 'W' for appending text to an existing file,
58 * 'wq' for exiting after a write, and
59 * 'z' for scrolling through the buffer.
61 * The POSIX interactive global commands 'G' and 'V' are extended to
62 support multiple commands, including 'a', 'i' and 'c'. The command
63 format is the same as for the global commands 'g' and 'v', i.e., one
64 command per line with each line, except for the last, ending in a
67 * The file commands 'E', 'e', 'r', 'W' and 'w' process a <file>
68 argument for backslash escapes; i.e., any character preceded by a
69 backslash is interpreted literally. If the first unescaped character
70 of a <file> argument is a bang (!), then the rest of the line is
71 interpreted as a shell command, and no escape processing is performed
74 * For SunOS ed(1) compatibility, GNU ed runs in restricted mode if invoked
75 as red. This limits editing of files in the local directory only and
76 prohibits shell commands.
80 * For backwards compatibility, the POSIX rule that says a range of
81 addresses cannot be used where only a single address is expected has
84 * To support the BSD 's' command (see EXTENSIONS above),
85 substitution patterns cannot be delimited by numbers or the characters
86 'r', 'g' and 'p'. In contrast, POSIX specifies any character expect
87 space or newline can used as a delimiter.
89 * Since the behavior of 'u' (undo) within a 'g' (global) command list is
90 not specified by POSIX, GNU ed follows the behavior of the SunOS ed:
91 undo forces a global command list to be executed only once, rather than
92 for each line matching a global pattern. In addtion, each instance of
93 'u' within a global command undoes all previous commands (including
94 undo's) in the command list. This seems the best way, since the
95 alternatives are either too complicated to implement or too confusing
98 * The 'm' (move) command within a 'g' command list also follows the SunOS
99 ed implementation: any moved lines are removed from the global command's
102 * If GNU ed is invoked with a name argument prefixed by a bang (!), then
103 the remainder of the argument is interpreted as a shell command. To invoke
104 ed on a file whose name starts with bang, prefix the name with a
107 * For backwards compatibility, errors in piped scripts do not force ed
108 to exit. POSIX only specifies ed's response for input via regular
109 files (including here documents) or tty's.
114 The files in the 'testsuite' directory with suffixes '.t', '.d', '.r',
115 '.pr' and '.err' are used for testing ed. To run the tests, configure
116 the package and type 'make check' from the build directory. The tests do
117 not exhaustively verify POSIX compliance nor do they verify correct
118 8-bit or long line support.
120 The test file suffixes have the following meanings:
121 .t Template - a list of ed commands from which an ed script is
123 .d Data - read by an ed script
124 .r Result - the expected output after processing data via an ed
126 .pr Result from a piped ed script.
127 .err Error - invalid ed commands that should generate an error
129 The output of the tests is written to files with .o and .ro suffixes and
130 compared with their corresponding .r and .pr result files.
131 If any test fails, the error messages look like:
133 *** The script u.ed exited abnormally ***
135 *** Output u.o of script u.ed is incorrect ***
138 Copyright (C) 1993, 1994 Andrew Moore
139 Copyright (C) 2006-2015 Antonio Diaz Diaz.
141 This file is free documentation: you have unlimited permission to copy,
142 distribute and modify it.
144 The file Makefile.in is a data file used by configure to produce the
145 Makefile. It has the same copyright owner and permissions that configure