# 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.

#!/bin/bash
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 call it “birthstone” rather than “birthtoken” because I would never remember “birthtoken.” Until I looked in this file, I didn’t even know there were birth flowers.
• The -i option makes grep case-insensitive, so I don’t have to capitalize anything.
• The sed part of the script replaces the colons in the birthtoken file with spaces and hyphens. I found that the colons were making Quicksilver think the output was a URL, so its default operation was Open URL. Replacing the colons caused QS’s default operation to change to Large Type, which is just what I wanted.
• Because grep searches the whole line, not just the first field, I can not only find the birthstone for a given month, I can also find the month associated with a given stone.

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

#!/bin/bash
grep -i $1$HOME/miscfiles/na.phone | sed 's/:/ - /g'


zipcode:

#!/bin/bash
grep -i $1$HOME/miscfiles/zipcodes | sed 's/:/ - /g'


and airport:

#!/bin/bash
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.