HOME

TheInfoList



OR:

(pronounced as distinct letters, ) is a
line editor In computing, a line editor is a text editor in which each editing command applies to one or more complete lines of text designated by the user. Line editors predate screen-based text editors and originated in an era when a computer operator typic ...
for
Unix Unix (; trademarked as UNIX) is a family of multitasking, multiuser computer operating systems that derive from the original AT&T Unix, whose development started in 1969 at the Bell Labs research center by Ken Thompson, Dennis Ritchie, and ot ...
and
Unix-like A Unix-like (sometimes referred to as UN*X or *nix) operating system is one that behaves in a manner similar to a Unix system, although not necessarily conforming to or being certified to any version of the Single UNIX Specification. A Unix-li ...
operating systems. It was one of the first parts of the Unix operating system that was developed, in August 1969. It remains part of the
POSIX The Portable Operating System Interface (POSIX) is a family of standards specified by the IEEE Computer Society for maintaining compatibility between operating systems. POSIX defines both the system- and user-level application programming inter ...
and
Open Group The Open Group is a global consortium that seeks to "enable the achievement of business objectives" by developing "open, vendor-neutral technology standards and certifications." It has over 840 member organizations and provides a number of servi ...
standards for Unix-based operating systems, alongside the more sophisticated full-screen editor vi.


History and influence

The ed text editor was one of the first three key elements of the Unix operating system—
assembler Assembler may refer to: Arts and media * Nobukazu Takemura, avant-garde electronic musician, stage name Assembler * Assemblers, a fictional race in the ''Star Wars'' universe * Assemblers, an alternative name of the superhero group Champions of ...
, editor, and
shell Shell may refer to: Architecture and design * Shell (structure), a thin structure ** Concrete shell, a thin shell of concrete, usually with no interior columns or exterior buttresses ** Thin-shell structure Science Biology * Seashell, a hard o ...
—developed by
Ken Thompson Kenneth Lane Thompson (born February 4, 1943) is an American pioneer of computer science. Thompson worked at Bell Labs for most of his career where he designed and implemented the original Unix operating system. He also invented the B programmi ...
in August 1969 on a
PDP-7 The PDP-7 was a minicomputer produced by Digital Equipment Corporation as part of the PDP series. Introduced in 1964, shipped since 1965, it was the first to use their Flip-Chip technology. With a cost of , it was cheap but powerful by the s ...
at
AT&T Bell Labs Nokia Bell Labs, originally named Bell Telephone Laboratories (1925–1984), then AT&T Bell Laboratories (1984–1996) and Bell Labs Innovations (1996–2007), is an American industrial research and scientific development company owned by mult ...
. Many features of ed came from the qed text editor developed at Thompson's alma mater
University of California, Berkeley The University of California, Berkeley (UC Berkeley, Berkeley, Cal, or California) is a public land-grant research university in Berkeley, California. Established in 1868 as the University of California, it is the state's first land-grant u ...
. Thompson was very familiar with qed, and had reimplemented it on the CTSS and
Multics Multics ("Multiplexed Information and Computing Service") is an influential early time-sharing operating system based on the concept of a single-level memory.Dennis M. Ritchie, "The Evolution of the Unix Time-sharing System", Communications of ...
systems. Thompson's versions of qed were notable as the first to implement
regular expression A regular expression (shortened as regex or regexp; sometimes referred to as rational expression) is a sequence of characters that specifies a search pattern in text. Usually such patterns are used by string-searching algorithms for "find" ...
s. Regular expressions are also implemented in ed, though their implementation is considerably less general than that in qed. Dennis M. Ritchie produced what
Doug McIlroy Malcolm Douglas McIlroy (born 1932) is a mathematician, engineer, and programmer. As of 2019 he is an Adjunct Professor of Computer Science at Dartmouth College. McIlroy is best known for having originally proposed Unix pipelines and developed s ...
later described as the "definitive" ed, and aspects of ed went on to influence ex, which in turn spawned vi. The non-interactive Unix command
grep grep is a command-line utility for searching plain-text data sets for lines that match a regular expression. Its name comes from the ed command ''g/re/p'' (''globally search for a regular expression and print matching lines''), which has the sa ...
was inspired by a common special use of qed and later ed, where the command g/re/p means globally search for the regular expression re and print the lines containing it. The Unix stream editor,
sed sed ("stream editor") is a Unix utility that parses and transforms text, using a simple, compact programming language. It was developed from 1973 to 1974 by Lee E. McMahon of Bell Labs, and is available today for most operating systems. sed w ...
implemented many of the scripting features of qed that were not supported by ed on Unix.


Features

Features of ed include: * available on essentially all Unix systems (and mandatory on systems conforming to the Single Unix Specification). * support for
regular expression A regular expression (shortened as regex or regexp; sometimes referred to as rational expression) is a sequence of characters that specifies a search pattern in text. Usually such patterns are used by string-searching algorithms for "find" ...
s * powerful automation can be achieved by feeding commands from
standard input In computer programming, standard streams are interconnected input and output communication channels between a computer program and its environment when it begins execution. The three input/output (I/O) connections are called standard input (stdin ...
(In)famous for its terseness, ed gives almost no visual feedback, and has been called (by
Peter H. Salus Peter Henry Salus is a linguist, computer scientist, historian of technology, author in many fields, and an editor of books and journals. He has conducted research in germanistics, language acquisition, and computer languages. Education and c ...
) "the most user-hostile editor ever created", even when compared to the contemporary (and notoriously complex) TECO. For example, the message that ed will produce in case of error, ''and'' when it wants to make sure the user wishes to quit without saving, is "?". It does not report the current filename or line number, or even display the results of a change to the text, unless requested. Older versions (c. 1981) did not even ask for confirmation when a quit command was issued without the user saving changes. This terseness was appropriate in the early versions of Unix, when consoles were teletypes,
modem A modulator-demodulator or modem is a computer hardware device that converts data from a digital format into a format suitable for an analog transmission medium such as telephone or radio. A modem transmits data by Modulation#Digital modulati ...
s were slow, and
memory Memory is the faculty of the mind by which data or information is encoded, stored, and retrieved when needed. It is the retention of information over time for the purpose of influencing future action. If past events could not be remembered, ...
was precious. As computer technology improved and these constraints were loosened, editors with more visual feedback became the norm. In current practice, ed is rarely used interactively, but does find use in some shell scripts. For interactive use, ed was subsumed by the sam, vi and Emacs editors in the 1980s. ed can be found on virtually every version of Unix and
Linux Linux ( or ) is a family of open-source Unix-like operating systems based on the Linux kernel, an operating system kernel first released on September 17, 1991, by Linus Torvalds. Linux is typically packaged as a Linux distribution, which ...
available, and as such is useful for people who have to work with multiple versions of Unix. On Unix-based operating systems, some utilities like
SQL*Plus SQL Plus is the most basic Oracle Database utility, with a basic command-line interface, commonly used by users, administrators, and programmers. Command types SQL Plus understands five categories of text: # SQL statements # PL/SQL blocks # SQL ...
run ed as the editor if the EDITOR and VISUAL environment variables are not defined. If something goes wrong, ed is sometimes the only editor available. This is often the only time when it is used interactively. The version of ed provided by
GNU GNU () is an extensive collection of free software (383 packages as of January 2022), which can be used as an operating system or can be used in parts with other operating systems. The use of the completed GNU tools led to the family of operat ...
has a few switches to enhance the feedback. Using provides a simple prompt and enables more useful feedback messages. The switch is defined in POSIX since XPG2 (1987). The ed commands are often imitated in other line-based editors. For example, EDLIN in early
MS-DOS MS-DOS ( ; acronym for Microsoft Disk Operating System, also known as Microsoft DOS) is an operating system for x86-based personal computers mostly developed by Microsoft. Collectively, MS-DOS, its rebranding as IBM PC DOS, and a few ope ...
versions and 32-bit versions of
Windows NT Windows NT is a proprietary graphical operating system produced by Microsoft, the first version of which was released on July 27, 1993. It is a processor-independent, multiprocessing and multi-user operating system. The first version of Win ...
has a somewhat similar syntax, and text editors in many MUDs (
LPMud LPMud, abbreviated LP, is a family of MUD server software. Its first instance, the original LPMud game driver, was developed in 1989 by Lars Pensjö (hence the LP in LPMud). LPMud was innovative in its separation of the MUD infrastructure into ...
and descendants, for example) use ed-like syntax. These editors, however, are typically more limited in function.


Example

Here is an example transcript of an ed session. For clarity, commands and text typed by the user are in normal face, and output from ed is emphasized. a This is line number two. . 2i   . ,l ed is the standard Unix text editor.$ $ This is line number two.$ 3s/two/three/ ,l ed is the standard Unix text editor.$ $ This is line number three.$ w text 65 q The end result is a simple text file containing the following text: ed is the standard Unix text editor.   This is line number three. Started with an empty file, the a command appends text (all ed commands are single letters). The command puts ed in ''insert mode'', inserting the characters that follow and is terminated by a single dot on a line. The two lines that are entered before the dot end up in the file buffer. The 2i command also goes into insert mode, and will insert the entered text (a single empty line in our case) before line two. All commands may be prefixed by a line number to operate on that line. In the line ,l, the lowercase L stands for the list command. The command is prefixed by a range, in this case , which is a shortcut for 1,$. A range is two line numbers separated by a comma ($ means the last line). In return, ed lists all lines, from first to last. These lines are ended with dollar signs, so that white space at the end of lines is clearly visible. Once the empty line is inserted in line 2, the line which reads "This is line number two." is now actually the third line. This error is corrected with 3s/two/three/, a substitution command. The 3 will apply it to the correct line; following the command is the text to be replaced, and then the replacement. Listing all lines with ,l the line is shown now to be correct. w text writes the buffer to the file "text" making ed respond with ''65'', the number of characters written to the file. q will end an ed session.


Cultural references

The
GNU GNU () is an extensive collection of free software (383 packages as of January 2022), which can be used as an operating system or can be used in parts with other operating systems. The use of the completed GNU tools led to the family of operat ...
project has numerous jokes around ed hosted on its website. In addition, the
glibc The GNU C Library, commonly known as glibc, is the GNU Project's implementation of the C standard library. Despite its name, it now also directly supports C++ (and, indirectly, other programming languages). It was started in the 1980s by ...
documentation notes an
error code In computer programming, a return code or an error code is a numeric or alphanumeric code that is used to determine the nature of an error and why it occurred. They are also commonly found in consumer electronics and devices when they attempt to ...
called with its description (errorstr) merely a single question mark, noting "the experienced user will know what is wrong."


See also

* Edlin, the standard MS-DOS line editor which was inspired by ''ed'' *
Sam (text editor) Sam is a multi-file text editor based on structural regular expressions. It was originally designed in the early 1980s at Bell Labs by Rob Pike with the help of Ken Thompson and other Unix developers for the Blit windowing terminal running on U ...
*
Editor war The editor war is the rivalry between users of the Emacs and vi (now usually Vim, or more recently Neovim) text editors. The rivalry has become an enduring part of hacker culture and the free software community. The Emacs versus vi debate was o ...
*
List of Unix commands This is a list of Unix commands as specified by IEEE Std 1003.1-2008, which is part of the Single UNIX Specification (SUS). These commands can be found on Unix operating systems and most Unix-like operating systems. List See also * List of G ...


References


External links

*
Manual page from Unix First Edition describing ed
* * , a direct descendant of the original ed.



section 3.1 describes the history of ed. {{Ken Thompson navbox Unix text editors MacOS text editors Standard Unix programs Unix SUS2008 utilities Plan 9 commands Line editor 1971 software Console applications