Subtracting two timestamps in bash script

后端 未结 3 1925
粉色の甜心
粉色の甜心 2021-01-11 18:00

I have a file that contains a set of Timestamps in format of H:M:S.MS, I can read and print all of the saved Timestamps but when I do some arithmetic operation

3条回答
  •  礼貌的吻别
    2021-01-11 18:27

    Assuming your variables are integers, you need to enclose your calculation in an arithmetic evaluation for that to work.

    echo $(( VAR1 - VAR2 ))
    

    Or, if you want to assign the value :

    VAR3=$(( VAR1 - VAR2 ))
    

提交回复
热议问题