运行脚本报错
#!/bin/bash
s=0
for (( i=1; i<=100; i++ ))
do
s=$(( $s + $i ))
done
echo $s
sh add.sh 报错:
add.sh: 4: Syntax error: Bad for loop variable
代码没有错误,Ubuntu为了加快开机速度,用dash代替bash。
解决办法:取消dash,使用bash:
sudo dpkg-reconfigure dash
选择No选项。