Format date output:
date +"%I:%M %p"date +"%I:%M %P"
Where:
%I hour (01..12)%M minute (00..59)%p locale's equivalent of either AM or PM; blank if not known%P like %p, but lower case
If you are using at least bash 4.2, you don't even need date:
bash
date
printf '%(%I:%M %p)T\n'
You can just replace the following line
echo $(date +"%r")
with
echo $(date +"%r" | sed -e 's/\([0-9][0-9]:[0-9][0-9]\):[0-9][0-9]/\1/')