Shell
shell程式語法錯誤
num1 = 20 num2 = 20 echo $(( num1 + num2 )) echo $(( num1 - num2 )) echo $(( num1 * num2 )) echo $(( num1 / num2 )) echo $(( num1 % num2 ))
錯誤 :
./practice.sh: line 53: num1: command not found ./practice.sh: line 54: num2: command not found 0 0 0 ./practice.sh: line 59: num1 / num2 : division by 0 (error token is "num2 ") ./practice.sh: line 60: num1 % num2 : division by 0 (error token is "num2 ")
我錯過了什麼?當我嘗試一些數字而不是
num1
和num2
內部迴聲時。我注意到它列印正確..但是,這裡發生了什麼..?
num1=20 num2=20
當我嘗試從 num1 和 num2 中刪除空格時。我注意到它正在工作