當前位置:編程學習大全網 - 編程軟體 - bash shell腳本遇到+0")syntax error: invalid arithmetic operator (error token is "的問題

bash shell腳本遇到+0")syntax error: invalid arithmetic operator (error token is "的問題

LINE="Tests run: 196, Failures: 1, Errors: 1"

error=`echo $LINE|cut -d':' -f4`

ERROR=0

ERROR=$(($error+$ERROR))

妳確定妳是在用b.sh不是其他shell執行這個腳本?還有,妳發的LINE=後面的引號是

全角的,是妳輸入錯誤還是原來腳本就用全角的? 把這下面這個復制粘貼到t.sh, 再報錯,就是妳系統的問題。我已經測試過兩遍了。

#!/bin/bash

LINE="Tests run: 196, Failures: 1, Errors: 1"

error=`echo $LINE|cut -d':' -f4`

echo $error

ERROR=0

ERROR=$(($error+$ERROR))

echo $ERROR

測試結果:

chmod +x t.sh

./t.sh

1

1

  • 上一篇:如何取消宏命令?
  • 下一篇:OSSD是啥?有用嗎?
  • copyright 2024編程學習大全網