Did grep Really Come Together in One Night? The True Origin of Its Name
The article recounts how the iconic Unix grep command was born in the early 1970s, tracing its roots from the ed editor, a linguist's need to analyze the Federalist Papers, and the clever reuse of existing code that led to the name derived from an ed command.
grep is one of the most recognizable Unix tools, commonly used for log analysis and code searching.
In the early 1970s, Unix was still nascent and the standard text editor was ed, written by Ken Thompson. Although ed supported regular expressions, it required loading the entire file into memory, making it impractical for even modest‑size texts.
Before screen‑based editors like vi appeared, users worked with line editors on teletypes, issuing commands that operated on whole lines.
Lee McMahon, a linguist, wanted to use a computer to determine the authorship of the 85‑essay Federalist Papers collection, which exceeded 1 MB—far beyond the memory capacity of the machines at the time.
McMahon asked Ken for a simple tool that could list the lines containing a given word. Ken already had a private utility called s that performed similar tasks, so he quickly adapted it, added a few fixes, and handed the program to McMahon the next day.
The resulting program scanned one or more files, printed every line that matched a regular expression, and was named grep. The name comes from the ed command g/<re>/p, meaning “globally search for <re> and print the matching lines.” Ken simply collapsed the command into the memorable word grep.
After McMahon used the tool for his text‑analysis, grep was incorporated into Unix Version 4 and became a classic example of the Unix philosophy: a small, focused utility that does one thing well.
Signed-in readers can open the original source through BestHub's protected redirect.
This article has been distilled and summarized from source material, then republished for learning and reference. If you believe it infringes your rights, please contactand we will review it promptly.
ITPUB
Official ITPUB account sharing technical insights, community news, and exciting events.
How this landed with the community
Was this worth your time?
0 Comments
Thoughtful readers leave field notes, pushback, and hard-won operational detail here.
