shell中while循环的常用写法
程序员文章站
2024-03-23 21:44:22
...
写法一:
#!/bin/sh
int=1
while (( "$int < 10" ))
do
echo "$int"
let "int++"
done
写法二:
#!/bin/sh
echo "please input the num"
read num
sum=1
while [ "$num" -gt 0 ]
do
let "sum=sum*num"
let "num--"
done
echo "the sum is $sum"