I have below code to calculate the time difference in mm:ss format. However its not working if I have values like 08/09. I saw in few blobs by adding #10 it will resolve , however its not working out for me. can anyone please help .
#!/bin/bash
start_ts=04:24:07
stop_ts=04:24:09
ts_get_sec()
{
read -r h m s <<< $(echo 10#$1 | tr ':' ' ' )
echo $(((h*60*60)+(m*60)+s))
}
START=$(ts_get_sec $start_ts)
STOP=$(ts_get_sec $stop_ts)
DIFF=$((STOP-START))
echo "$((DIFF/60)):$((DIFF%60))"
Error I am getting:
value too great for base (error token is "09")
Please suggest if syntactically I am correct or not.