Pages

Tuesday, February 5, 2019

Convert string to numeric & perform arithmetic


Converting time stamp value : 12:07:06.460

dttm="12:07:06.460"
tm1=$(echo "${dttm_beg//[:.]/}")

integer: tm2=$(($tm1 + 1)); echo $tm2
float: tm2=$(echo "$tm1 + 1.1" | bc -l); echo $tm2