Subtract two variables in Bash

后端 未结 8 1926
时光取名叫无心
时光取名叫无心 2020-12-02 06:33

I have the script below to subtract the counts of files between two directories but the COUNT= expression does not work. What is the correct syntax?

<         


        
8条回答
  •  一生所求
    2020-12-02 06:59

    Try this Bash syntax instead of trying to use an external program expr:

    count=$((FIRSTV-SECONDV))
    

    BTW, the correct syntax of using expr is:

    count=$(expr $FIRSTV - $SECONDV)
    

    But keep in mind using expr is going to be slower than the internal Bash syntax I provided above.

提交回复
热议问题