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.
time=125959
echo "${time:0:2}":"${time:2:2}":"${time:4:2}"
I like sed
:
time=125959
sed -e "s/\(..\)\(..\)\(..\)/\1:\2:\3/" <<< "$time"
.
with [[:digit:]]
<<<
(Here strings) in man bash(1)