added functions from http://www.sudobash.net/bash-functions/