I need to turn the string "125959" into "12:59:59".
Obviously, the string is the time so regular expressions aren't much good here.
I need to turn the string "125959" into "12:59:59".
Obviously, the string is the time so regular expressions aren't much good here.
I like sed:
time=125959
sed -e "s/\(..\)\(..\)\(..\)/\1:\2:\3/" <<< "$time"
. with [[:digit:]]<<< (Here strings) in man bash(1)