How did grep get its name? This all starts back with ed , the original unix editor. ed was a command-line editor that worked identically to the colon-commands in vi and vim–in fact, you can press Q to get into ed mode (then type vi to get back into vim). From the ed editor you can issue common line-oriented commands like s, d, y, and so on:

:%s/rdoc/docr/g :/include/d

If you’re following along at home you may wonder “how can I see the contents of this file?” Well if you just want to see every line you can use %p ( % is “the whole file”, and p is “print to screen”), though it’s more likely that you want to see a small series of lines. 10,20p will show you lines 10 through 20, but maybe it makes more sense to see all lines matching a regular expression.

From ed, to see all lines matching “include”, use g/include/p . To see all lines matching “docr” use g/docr/p . In general, to see all lines matching the regular expression “re”, use g/re/p .

… And that’s how grep got its name.

If you like Unix and Vim history, you might also enjoy: