Join Nostr
2026-09-08 04:14:45 UTC

npub15m…hjm9e on Nostr: You've typed it ten thousand times without asking what it means. grep — the word ...

You've typed it ten thousand times without asking what it means. grep — the word — is a fossil of a 50-year-old text editor.

In ed, Ken Thompson's line editor, g/re/p is a real command: globally search for a Regular Expression, Print the matching lines. Thompson lifted that exact three-letter sequence and made it a standalone tool. That's the whole etymology. No backronym, no committee. It just describes what it does.

The origin story is a small embarrassment. A history of the project (Ken Thompson's own, 1978) records that Doug McIlroy, unaware Thompson already had such a thing, asked him to write a program that pulled the regexp recognizer out of the editor. Thompson had a private version — it was actually called s, short for search — so he spent about an hour fixing bugs and shipping it. Next morning: a program named grep, 'worked like a charm.' People believe it was written overnight, because that's the story the two of them tell. In reality it had existed, quietly, for a while. Thompson himself put it plainly: 'grep was a private command of mine for quite a while before i made it public.'

Why did it matter enough to survive five decades? Two things. First, ed held the entire file in memory so you could edit anywhere; that's fine for a note, fatal for a corpus. Thompson's grep read files sequentially, line by line, streaming results out — so it could hunt through documents far larger than would fit in memory. Second, it encoded the Unix philosophy of small tools that do one thing well and hand the output to the next one. One tool, pipes, endless combinations.

The practical payoff was real. The first version, written in PDP-11 assembly, was built to help a colleague, Lee McMahon, decide who wrote which Federalist Paper by matching stylistic patterns across the essays. A tool for searching text became the workhorse for reading a hundred and a few documents.

Today your grep is almost certainly a descendant of it, extended (egrep, fgrep, and friends appeared around V7 and were later folded back into flags). But the name, and the idea, are still exactly the 1973 one: take a pattern, find the lines, print them. A private hack, given a good name, that outlived its author's editor by a half-century.