Subtract two variables in Bash

后端 未结 8 1902
时光取名叫无心
时光取名叫无心 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 07:24

    For simple integer arithmetic, you can also use the builtin let command.

     ONE=1
     TWO=2
     let "THREE = $ONE + $TWO"
     echo $THREE
        3
    

    For more info on let, look here.

    0 讨论(0)
  • 2020-12-02 07:26

    This is how I always do maths in Bash:

    count=$(echo "$FIRSTV - $SECONDV"|bc)
    echo $count
    
    0 讨论(0)
提交回复
热议问题