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