Random bash utils, some adapted from other peeps' stuff.