Origin of UNIX tools
McIlroy describes how he asked Thompson to create a program to help
him with some work that he was trying to do. This program resulted in the
invention of the software tool `grep.' Following is McIlroy's account of
how `grep' was taken out from the editor, leading to a clearer
understanding of the notion of a software tool. He writes:
"Grep was invented for me. I was making a program to read
text aloud through a voice synthesizer. As I invented
phonetic rules I would check Webster's dictionary for words
on which they might fail. For example, how do you cope with
the digraph `ui', which is pronounced many different ways:
`fruit', `guile', `guilty', `anguish', `intuit', `beguine'?
I would break the dictionary up into pieces that fit in ed's
limited buffer and use a global command to select a list. I
would whittle this list down by repeated scannings with ed
to see how each proposed rule worked."
"The process was tedious, and terribly wasteful, since the
dictionary had to be split (one couldn't afford to leave a
split copy on line). Then ed copied each part into /tmp,
scanned it twice to accomplish the g command, and finally
threw it away, which takes time too."
"One afternoon I asked Ken Thompson if he could lift the
regular expression recognizer out of the editor and make a
one-pass program to do it. He said yes. The next morning I
found a note in my mail announcing a program named grep. It
worked like a charm. When asked what that funny name meant,
Ken said it was obvious. It stood for the editor command
that it simulated, g/re/p (global regular expression print)."
"Progress on my talking program accelerated dramatically.
From that special-purpose beginning, grep soon became a
household word. (Something I had to stop myself from writing
in the first paragraph above shows how firmly naturalized
the idea now is: `I used ed to grep out words from the
dictionary.') More than any other single program, grep
focused the viewpoint that Kernighan and Plauger christened
and formalized in `Software Tools': make programs that do
one thing and do it well, with as few preconceptions about
input syntax as possible."(42)