Generated by GPT-5-mini| ed (Unix) | |
|---|---|
| Name | ed |
| Author | Ken Thompson, Dennis Ritchie |
| Released | 1969 |
| Operating system | Unix, Plan 9, Linux, BSD |
| Genre | Text editor |
| License | Various |
ed (Unix) is a line-oriented text editor originally developed for the Unix operating system by Ken Thompson and Dennis Ritchie at Bell Labs in 1969. It served as the canonical editor for early Version 1 through Research Unix releases and influenced later editors such as ex and vi. ed remains notable for its minimal interface, portability across POSIX systems, and role in the development of software tools and text processing on early multics-era systems.
ed was created by Ken Thompson and Dennis Ritchie during the formative period of Unix development at Bell Labs alongside utilities like the Thompson shell and the C programming language. Early implementations appeared on PDP-11 hardware and were distributed with the first releases that circulated in academic settings including UC Berkeley and MIT. ed's design reflected constraints of PDP-7 and PDP-11 terminals and storage, shaping later editors such as ex, vi, and the GNU Emacs family. Over decades ed was ported to Plan 9, integrated into 4.4BSD distributions, and maintained in GNU coreutils and netbsd trees, preserving compatibility with POSIX standards and historical Software Heritage artifacts.
ed's architecture emphasizes a minimal, line-oriented model optimized for remote teletypes and constrained terminals like the Teletype. Its internal buffer uses a gap or linked structure influenced by early text editor research at Bell Labs and supports addressing by line numbers and regular expressions tracing roots to Thompson's pattern-matching work. Features include command-driven editing, global and substitute operations using regular expressions from the Thompson regex lineage, and interaction with external filters such as sed and awk for pipeline integration. ed's design priorities—small binary size, predictable behavior, and scriptability—made it suitable for inclusion in bootstraps and recovery environments in systems like 4.3BSD and Research Unix.
ed operates via single-letter commands and address ranges, following conventions established in early Unix manual pages. Typical commands include append (a), change (c), delete (d), print (p), substitute (s), and write (w), with addressing using numeric ranges, dollar ($) for end-of-buffer, and dot (.) for current line—notations familiar from edward-style editors used in Version 7 Unix documentation. Regular expressions in ed reflect the Thompson regular expressions tradition and influenced engines in grep and regex libraries. ed's scripting model permits batch editing through command files and non-interactive invocation, enabling automation in shell scripting contexts such as Bourne shell scripts and early make workflows.
Common ed workflows include recovering corrupted files on single-user systems, performing scripted transformations invoked from cron jobs, and as a fallback editor in rescue or minimal environments like initramfs and system rescue consoles. Examples demonstrate line-addressing: specifying "1,$p" prints an entire buffer, "2,5d" deletes lines two through five, and "s/old/new/g" performs substitutions—operations paralleling examples in Unix Programmer's Manual and The UNIX Programming Environment by Brian Kernighan and Rob Pike. ed is often used in combination with filters like sort, uniq, and tr to construct pipelines in shell sessions, and its non-graphical interface suits automation in continuous integration scripts on systems such as Debian, Ubuntu, FreeBSD, and NetBSD.
Multiple implementations and distributions of ed exist, ranging from the original Research Unix source to modern ports in GNU projects, Plan 9 variants, and lightweight replacements in BusyBox and Toybox. Notable maintainers and contributors include developers associated with NetBSD and OpenBSD who preserved ed in base systems, and projects like GNU ed which provide portable, POSIX-compliant binaries. Derivative editors such as ex and edlin (on earlier MS-DOS ports) reflect ed's command set, while full-screen successors like vi and vim extended its capabilities for interactive terminals produced by vendors like DEC and IBM. ed's longevity is supported by archival efforts at Software Heritage and historical retrospectives in publications by ACM and contributors from Bell Labs.
Category:Unix text editors Category:Bell Labs software