Improved my bash "count" function.