Python and shell solutions to the Knuth-McIlroy word count problem.
Switch branches/tags
Nothing to show
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Failed to load latest commit information.

The Wordcount Problem

Here are some scripts relating to the "word count problem" that was the subject of a memorable exchange between Donald Knuth and Doug McIlroy. See here for context.

Files Included

McIlroy's original 6-line shell pipeline is in

My Python solution to the same original problem is in

My extended Python solution that correctly handles contractions is in

An extended shell pipeline that correctly handles contractions is in

A test text file for use as input is in wordcounttest.txt.

The expected outputs of the two versions, when run on the test text file, are in wordcount.out and ewordcount.out. Note that the outputs include all of the words in the file; I generated them by using a large number (150) as the argument to each script.