function format_time() { HMS_HOURS=$(expr $1 / 3600) HMS_MINS=$(expr \( $1 % 3600 \) / 60) HMS_SECS=$(expr $1 % 3600 % 60) test "$HMS_HOURS" -lt 10 && HMS_HOURS="0${HMS_HOURS}" test "$HMS_MINS" -lt 10 && HMS_MINS="0${HMS_MINS}" test "$HMS_SECS" -lt 10 && HMS_SECS="0${HMS_SECS}" echo "${HMS_HOURS}:${HMS_MINS}:${HMS_SECS}" } format_seconds() { LC_ALL="C" awk '{ hr=($1/3600); hd=(sprintf("%02d", hr)) mr=((hr-hd)*60); md=(sprintf("%02d", mr)) s=((mr-md)*60); sd=(sprintf("%02d", s)) t=(sprintf("%02d:%02d:%06.3f" ,hd,md,s)); print t}' <<< $1 }