More Unix tidbits for OS X

As I said in this earlier post, Unix and Linux computers usually have an assortment of files with interesting bits of information. With a Mac, you can make this information more available to you by combining the Unix philosophy of text files and pipes with Quicksilver. This post will show a few more ways I’ve combined the two.

The /usr/share/misc folder is the normal place for interesting little files. Unfortunately, the Mac does not have the full complement of files that you’d probably find on a Linux machine. I went to this Free Software Foundation page and downloaded their miscfiles package, which is more complete. I ungzipped the files and put them in a miscfiles folder in my home directory. Now I’m ready to write some short shell scripts to access the info.

The first one pulls information from the birthtokens file, a file that Apple did include in /usr/share/misc and is also in the miscfiles package. I call the script birthstone and I keep it in my ~/bin folder.

grep -i $1 $HOME/miscfiles/birthtoken | sed 's/:/ - /g'

From the Terminal, this script would be invoked by a line like birthstone march and it would return March - Aquamarine - Jonquil. Even better, because Quicksilver has my ~/bin folder cataloged, I can call this script from QS.

  1. Bring up Quicksilver (I use Control-Space).
  2. Start typing “birthstone.”
  3. Tab over to the third pane and type in the search string.
  4. Hit Return and wait for the output to appear in a new QS command window.
  5. Hit Return again to show the results in Large Type.

The process looks like this (the windows have been scaled to fit the blog):

A few notes on why the script is written the way it is:

I’ve written a few other scripts that do basically the same thing with other files in the miscfiles package. More useful scripts include areacode

grep -i $1 $HOME/miscfiles/ | sed 's/:/ - /g'


grep -i $1 $HOME/miscfiles/zipcodes | sed 's/:/ - /g'

and airport:

grep -i $1 $HOME/miscfiles/airport | sed 's/:/ - /g'

The airport script associates the airport with its three-letter code. The others should be self-explanatory.

I realize all this information is available on the net, but using these scripts is better than searching the net. They’re faster than Google, and when used with Quicksilver, I don’t have to switch from whatever program I’m in to my browser.