# for 写法一:
for ((初始值;条件;增长))
do
echo "循环输出"
done
# for 写法二:
for ((初始值;条件;增长)); do
echo "循环输出"
done
# forin 写法一:
for item in 数据列表
do
echo "循环输出"
done
# forin 写法二:
for item in 数据列表; do
echo "循环输出"
done
$ echo {1..10}
1 2 3 ... 10
$ echo {a..z}
a b c d ... z
for ((i=0;i<10;i++)); do
echo "${i}"
done
输出:
0
1
2
...
10
for item in {a..z}; do
echo "${item}"
done
输出:
a
b
c
d
...
z
for item in {1..10}; do
echo "${item}"
done
输出:
1
2
3
4
...
10
for item in 1 3 5 7 9; do
echo "${item}"
done
输出:
1
3
5
7
9