grep

grep is one of the most used programs on a Unix system: give it a pattern and one or more files, and it prints the lines that match. The Version 7 Unix manual page describes the family plainly: “grep, egrep, fgrep - search a file for a pattern,” with matching lines copied to standard output. It is a textbook example of a Unix filter, a small program that reads text, selects part of it, and writes text back out.

The name records its origin in the line editor ed. In ed, the command g/re/p means “globally find lines matching this regular expression and print them.” Pulling that operation out of the editor into a standalone command gave grep its memorable name, and the program inherited ed’s pattern notation.

According to the Version 7 manual page, grep accepts limited regular expressions in the style of ed, while its sibling egrep accepts full regular expressions with operators such as alternation and grouping, and fgrep matches fixed strings. The choice lets a user trade pattern power for speed depending on the job.

Because grep reads and writes plain text, it slots naturally into pipelines: programs feed lines into grep, and grep feeds its matches onward to sort, count, or display. That combination of a focused job and a clean text interface is exactly the design the Unix group prized, and it helped make grep a verb in programmer slang.

Sources

Last verified June 7, 2026