#!/bin/bash
sum=10 i=0
while [ $i -le $sum ]
do
i = $[$i+1]
echo $i
done
这里有个报错:
line 6: i: command not found
我试了很多次比如bash -n xxx.sh但是无用
改了一下运算符使用就通了:
#!/bin/bash
sum=10
i=0
while [ $i -le $sum ]
do
i=$((i+1))
echo $i
done
我这里是20多的版本