Update code files in /usr/share/misc

Aug 08, '03 10:20:00AM

Contributed by: Anonymous

As previously mentioned on this site, there are many useful text files in /usr -> share -> misc, containing such useful information as zip codes, airport codes, area codes and more. Problem is, the versions shipped with OS X are very out-of-date. Here's a little shell script that will update them.


#!/bin/sh

# update_codes.sh
#
# very simple script to update airport, phone and zip codes kept
# in /usr/share/misc from source data at the openbsd site.  

base_url='http://www.openbsd.org/cgi-bin/cvsweb/~checkout~/src/share/misc'
code_list='airport inter.phone na.phone zipcodes'

for code_type in $code_list; do
   echo "downloading $code_type..."
   src="$base_url/$code_type"
   dest="/usr/share/misc/$code_type"
   mv $dest ${dest}.bak
   curl $src > $dest
done
As previously mentioned here, you may use the very cool Code Finder utility to view and search these files.

[robg adds: This script works as described, though you'll need to remember to make it executable (chmod 755 update_codes) and run it as root (sudo update_codes). Replace update_codes with whatever you named the script.]

Comments (28)


Mac OS X Hints
http://hints.macworld.com/article.php?story=20030806155951171