The History of cat

Over at Two-Bit History Sinclair Target makes the case that although it seems as if computer technology is always advancing and changing, we are still using software that is virtually unchanged from the dawn of the computer age. As a case study he looks at the history of the cat command.

The cat command was in the first edition of Unix in 1969 and has been there ever since. Target looks at the code to see how much it’s changed since then. Thompson wrote the first version in PDP assembly language and it wasn’t until the 7th edition that it was rewritten in C.

Most of the changes since then have been the usual accretion of features and their flags. So many flags were added that Rob Pike complained about it in his famous essay UNIX Style, or cat -v Considered Harmful. Nonetheless, the heart of the utility remains the two lines

while ((c = getc(fi)) != EOF)
    putchar(c);

Target provides a link to gist that contains all the implementations of cat that he discusses (including those written in assembly) so you can see how things have changed. He concludes that the macOS version of cat that he uses today has not changed at all in 13 years. If you like reading through code and enjoy Unix history, be sure to take a look at Target’s post.

This entry was posted in General and tagged , . Bookmark the permalink.