Skip to content

sed — Trivia & Interesting Facts

Surprising, historical, and little-known facts about sed.


sed was the first Unix stream editor, written in 1974

Lee McMahon created sed (stream editor) at Bell Labs in 1974, making it one of the oldest Unix text processing tools still in daily use. sed was designed to apply editing commands to text streams non-interactively — a radical idea when most text editing was done in interactive editors like ed. Its s/pattern/replacement/ syntax directly influenced Perl, Python, and vim.


sed can do Turing-complete computation using its hold space

sed has two buffers: the pattern space (current line) and the hold space (persistent storage across lines). Using the h, g, x (exchange), and branch (b, t) commands, sed can implement arbitrary computation. People have written calculators, sorting algorithms, and even Tetris in sed, though the resulting scripts are essentially unreadable.


The -i flag (in-place editing) was added to GNU sed but is not POSIX

POSIX sed has no in-place editing capability — the original design only reads from stdin and writes to stdout. GNU sed added -i for in-place editing, but macOS/BSD sed requires -i '' (with an empty string argument) while GNU sed uses -i alone. This difference breaks shell scripts that try to be portable across Linux and macOS.


sed's address ranges enable surgical precision on files

sed can apply commands to specific line ranges (5,10s/old/new/), pattern ranges (/start/,/stop/d), or relative addresses (/pattern/,+3p). The combination of address ranges with multiple commands (-e) allows complex file transformations in a single pass. This capability makes sed the backbone of many automated configuration management scripts.


The one-liner culture around sed predates Stack Overflow by decades

Eric Pement's "sed one-liners" collection (first published in the 1990s) became a canonical reference passed between Unix administrators. These collections demonstrated common tasks like removing duplicate lines, reversing file contents, and converting file formats in single command-line invocations. They served as a distributed knowledge base before the web era.


sed's substitute command inspired vim's :s command

The :s/pattern/replacement/flags syntax in vim is a direct descendant of sed's substitute command. Both trace their lineage to ed, the original Unix line editor. sed was literally built as a non-interactive version of ed, and vim inherited ed's command syntax through ex. When you use :s in vim, you are using sed's grammar.