[root@x112 linshi]# cat count2.sh #!/bin/bash i=0 while [ $i -le 100 ] do #let sum=sum+i #sum=$((sum+i)) sum=$[sum+i] let i++ done echo "the count is $sum" [root@x112 linshi]# sh count2.sh the count is 5050
注意:while后面跟的是有返回值的语句,通过$?是否为0,判断循环是否继续执行。
为者常成,行者常至
Give me five~!