LLMpediaThe first transparent, open encyclopedia generated by LLMs

ed (text editor)

Generated by DeepSeek V3.2
Note: This article was automatically generated by a large language model (LLM) from purely parametric knowledge (no retrieval). It may contain inaccuracies or hallucinations. This encyclopedia is part of a research project currently under review.
Article Genealogy
Parent: Ken Thompson Hop 4
Expansion Funnel Raw 47 → Dedup 0 → NER 0 → Enqueued 0
1. Extracted47
2. After dedup0 (None)
3. After NER0 ()
4. Enqueued0 ()
ed (text editor)
Nameed
DeveloperKen Thompson
Released0 1971
Operating systemUnix, Unix-like
GenreText editor
LicenseOriginally proprietary, now part of BSD

ed (text editor). ed is a line editor for Unix and Unix-like operating systems, created by Ken Thompson at Bell Labs in the early 1970s. It was one of the first key components of the original Unix environment, providing a minimalist, modal interface for creating and modifying text files directly from the command-line interface. Its design emphasized scriptability and efficiency in low-bandwidth environments, influencing the development philosophy of many subsequent Unix tools.

History and development

ed was developed by Ken Thompson beginning in 1969, with its origins tracing to an earlier editor on the GE-635 mainframe and the QED editor. It became a standard part of the First Edition Unix released from Bell Labs in 1971. The editor was written in assembly language for the PDP-7 and later the PDP-11, embodying the minimalist principles of the early Unix philosophy. Its development was closely tied to other foundational tools like the Thompson shell and the C programming language. A major reimplementation in C by Brian Kernighan appeared in the Seventh Edition Unix in 1979, enhancing its portability and solidifying its role. The original BSD release included ed, and its source code was later distributed under a BSD license.

Features and operation

ed operates as a modal editor, distinctively separating command mode from text input mode, a concept later adopted by vi. It uses a simple command-line interface where all editing is performed by issuing terse, single-letter commands, such as `a` for append or `d` for delete, often preceded by line addresses. The editor is designed to be used with a teletype or a very slow terminal, producing no default output unless explicitly requested with commands like `p` for print. It supports regular expressions for powerful search and pattern-based addressing, a feature pioneered by its predecessor QED. Scripting and automation are central, as sequences of ed commands can be piped from a file or another shell command, making it a forerunner in pipeline-based text processing.

Usage and examples

A typical editing session begins by invoking ed with a filename, such as `ed document.txt`. The user then enters command mode, where they can navigate and edit using addresses like `1,5p` to print the first five lines or `/pattern/` to search. To insert text, one issues the `a` command, enters input mode to type lines, and terminates with a period on its own line. For instance, to substitute a word, the command `s/old/new/` is used on the current line. ed was historically used to write early Unix documentation, source code for programs like the B language, and system configuration files. Its command-driven nature made it ideal for shell scripts, where it could perform automated edits non-interactively, a technique preserved in the sed stream editor.

Influence and legacy

ed had a profound and lasting impact on the ecosystem of Unix and computing at large. It directly inspired the creation of the sed stream editor and the ex editor, with the latter's visual mode evolving into the ubiquitous vi and, by extension, Vim. Its emphasis on regular expressions and programmable filtering became a cornerstone of the Unix philosophy. The editor's terse, sometimes opaque, error feedback—famously just a `?` for many errors—became a cultural touchstone and was referenced in the fortune program and the Jargon File. While largely superseded by full-screen editors, ed remains specified by the POSIX and Single UNIX standards, ensuring its presence on all compliant systems, including Linux distributions and BSD variants.

Several standard Unix commands evolved from or were designed to complement ed. The most significant is sed, the stream editor, created by Lee E. McMahon to apply ed-like editing commands to streams of text in shell scripts. The ex editor extended ed with a visual mode, leading directly to vi. The grep command, whose name derives from the ed command `g/re/p` (globally search for a regular expression and print), shares its pattern-matching syntax. Later line editors like GNU's GNU ed and the SAM editor from Bell Labs expanded on its concepts. Its influence is also seen in non-Unix editors, such as the EDLIN line editor in MS-DOS and early versions of Microsoft Windows.

Category:Text editors Category:Unix text editors Category:Unix software Category:1971 software