How is there not a standard tool for this already? Bogus.
Tonight I'll rewrite the above shell script in C because it makes no sense to not write something so simple in C and package it up and distribute (at least for Linux and Darwin which is what I care about most).
*<RANT> Also note I begrudgingly add this for Darwin only because every dev I work with at work uses it. Hate it. Pointless when deploying to other NIXes. Why? </RANT>