1.for循环输出1-10的四种方法
#!/bin/bash
for ((i=1;i<=10;i++))
do
echo $i
done
#!/bin/bash
i=1
for ((;i<=10;i++))
do
echo $i
done
#!/bin/bash
i=1
for ((;i<=10;))
do
echo $i
let i++
done
#!/bin/bash
i=1
for ((;;))
do
if [ $i -le 10 ]
then
echo $i
let i++
else
exit 0
fi
done
2.奇数偶数求和
网友评论