Different loop in Bash
方法一
#!/bin/bash
for i in `seq 1 10`
do
#code here
echo $i
done
方法二
C语言风格
#!/bin/bash
for ((i=1; i<=10; i++))
do
printf "%s\n" "$i"
done
方法三
#!/bin/bash
i=1
while [ "$i" -lt "10" ]
do
#code here
echo $i
#i=$[ $i + 1 ]
((i++))
done
Disclaimer
- License under
CC BY-NC 4.0
- Copyright issue feedback
me#imzye.me
, replace # with @ - Not all the commands and scripts are tested in production environment, use at your own risk
- No privacy information is collected here