方法一:
1 #!/bin/bash 2 for i in `seq 1 10` 3 do 4 #code here 5 echo $i 6 done
方法二:C语言风格
1 #!/bin/bash 2 for ((i=1; i<=10; i++)) 3 do 4 printf "%s\n" "$i" 5 done
方法三:
1 #!/bin/bash 2 i=1 3 while [ "$i" -lt "10" ] 4 do 5 #code here 6 echo $i 7 #i=$[ $i + 1 ] 8 ((i++)) 9 done
时间: 2024-10-05 19:02:46