noqqe » blog | sammelsurium | photos | projects | about

Bash Time Conversion

2012-08-26 @ Bash, Programming

Gefunden auf unstableme

#!/bin/sh
#Convert seconds to h:m:s format

[ -z ${1} ] && echo "Usage: $(basename $0) <seconds>" && exit||secs=${1}
_hms()
{
 local S=${1}
 ((h=S/3600))
 ((m=S%3600/60))
 ((s=S%60))
 printf "%dh:%dm:%ds\n" $h $m $s
}

_hms ${secs}