Rewrite in Bash

Bash will be a little more portable than Ruby.