Simple way to convert HH:MM:SS (hours:minutes:seconds.split seconds) to seconds
Try this:
T='00:20:40.28'SavedIFS="$IFS"IFS=":."Time=($T)Seconds=$((${Time[0]}*3600 + ${Time[1]}*60 + ${Time[2]})).${Time[3]}IFS="$SavedIFS"echo $Seconds
($<string>) splits <string> based on the splitter (IFS
).
${<array>[<index>]} returns the element of the <array> at the <index>.
$((<arithmetic expression>)) performs the arithmetic expression.
Hope this helps.