10 Things a 38-Year-Old Book Taught Me About Unix
1984 is ancient.
In a field as young as computer science, reading a book of this age is like reading about building a house in the middle ages; the tools, circumstances, and needs, were so different that the relevance today is limited.
So is there still anything to be learned from a book this old? Yes there is! (Especially if you also count fun-facts, that have almost no use today, as learnings.)
Here are 10 things I learned from reading The UNIX Programming Environment. How many of them did you know?
10. The “Delete” key used to be called “Rub Out” (p. 3)
I wonder if we would be saying “I'll just rub out that paragraph”, if this had not changed.
I have not been able to figure out exactly when or why “Rub Out” became “Delete”, but I think the pencil rubber analogy is quite nice.
9. You Can Chat Directly In Your Terminal (p. 9)
Unix has built-in chat!? If you aren’t as surprised by this as I was, bear in mind that this is way before Facebook Messenger (2008), Skype (2003), WhatsApp, MSN (1999), and AOL (1997).
It was basically before the internet became a thing.
Therefore, Unix’s 'write' utility could initially only be used to communicate with users on the same machine.
8. 'echo' Can Check How Wildcards Are Expanded (p. 27)
Do you ever find yourself in doubt if running
$rm rub*.png
will delete exactly the files you want it to? Next time, use 'echo' to check which files the glob pattern matches:
$echo rub*.png
rubout2_crop.jpg rubout2.jpg rubout.jpg
$
Previously, I have always used 'ls' for this purpose, but 'echo' is better since it doesn’t list the content of directories.
7. Glob Patterns Are Expanded By The Shell (p. 74)
The reason I was surprised about the usage of 'echo' in 8 was not because I didn’t understand 'echo', it was because I didn’t understand the shell.
In the example in 8 it is the shell, not 'echo', that does the necessary pattern matching of the files. In fact, 'echo' doesn’t even know that a wildcard (*) has been specified, it just receives 3 arguments which it happily prints.
If you are also unsure what the shell really is, then read What Is the Unix Shell? from the book “Unix Shell Programming”.
See this wonderful old clip to hear the author talk about the shell’s role in Unix (skip to [4:55]).
6. Unix Can Show You (very) Local News (p. 10)
Just like we learned about chat in 9, Unix also has a 'news' utility.
By writing files in the /usr/news directory, users can share news with people that are using the same machine—likely to inform about system changes, downtime, etc..
Nowadays an email will probably suffice.
5. 'grep' Is An Acronym (p. 18)
Unix utilities have a tradition for short and cryptic names, but there is usually a reason behind the madness.
- 'cd' stands for “change directory”
- 'cat' is the 3 first letters of the not-so-used word catenate (which means roughly the same as concatenate)
- 'grep' is an acronym of global regular expression print
See the author’s own explanation for more detail. (This time in a bit more recent version than 7.)
4. Unix Makes It Easy To Be Nice (p. 35)
Do you ever find niceness to be a complex sociological process, that repeatedly leaves you in a state of analysis paralysis? Unix got you covered; it has a command for it.
The 'nice' utility lets you down prioritize your own job, leaving more processor power for those that share the machine with you.
While this might have been relevant in 1984—where some systems printed so slowly on the terminal, that a pager wasn’t needed to stop the output—it probably doesn’t see much use any more.
One possible case for using it is together with 'nohup':
$ nohup nice ...
3. Files Are Physical Things (p. 46)
This one is simple, but hit me pretty hard. I have never made the connection between files on a computer and a physical file. I knew both things, but never realised that computer files are named so because they resemble files.
I think this happens more frequently than we realise.
Technology is designed to mimic something we already know and understand, to make it easier to understand the new technology. Yet with time, as the technology becomes more popular, the relationship is forgotten.
As another example of this, rumor has it that there are people younger than me, and that some of them thinks that floppy disks are 3D-printed save icons.
2. Alignment Between Options Has Always Been a Problem (p. 14)
When learning Unix it is not just challenging to learn all the utilities, but also to learn all the utilities’ options.
This is especially challenging because option names aren’t aligned. For example the option '-c' when used with 'ls' sorts the files listed by timestamp, but when used with 'cut' it selects characters by index.
When I first encountered this I assumed that this misalignment had happened over time; that it all started out in order but then, as the system got more complex, everything slowly descended into chaos.
I was utterly wrong.
In fact, it appears the author made the same mistake that I did, but in reverse. He hoped that the ambiguity would be resolved in the future:
... you will find that there is little regularity or system to optional arguments.
Although the situation is improving—new versions often have more uniformity—all we can suggest is that you try to do better when you write your own programs...
1. Unix Can Be So Ridiculously Elegant (p. 97)
If you made it this far, you are probably no stranger to Unix’s elegance and simplicity.
However, I wanna share a snippet from the book which illustrates this better than anything I have seen before.
The Bundle Program
# bundle: group files into distribution package
echo '# To unbundle, sh this file'
for i
do
echo "echo $i 1>&2"
echo "cat >$i <<'End of $i'"
cat $i
echo "End of $i"
done
While short, this program is hard to digest.
It is a program which creates its own inverse. Execute it to bundle together the content of the files that are given as arguments. Execute the resulting file and it is unraveled into the original list of input files with all their content. Marvelous!
(See the description of the bundle program in the book for a better and more detailed explanation.)
Should You Read This Book?
Let’s be clear: If you are new to Unix and want to learn more, this is not the book to start with.
However, if you are fascinated by Unix, and would like some tales and insights from a long gone time in computing, it is worth a read.
In this post I have covered the things I found interesting and that surprised me, but to a large extend the descriptions is the book are still valid today. The majority of the utilities it covers are still found on modern Unix-like systems.
The fact that these fundamental parts of Unix haven’t changed for such a long time—making a 38 year old book still useful—is exceptional.
It is as a testament to how well-designed the Unix system is—and always has been.