步进循环语句for
一、for语句的基本格式
for 变量 in 列表 do 语句块 done
二、使用for语句处理列表(数组)
[root@localhost shell]# cat use_for_deal_with_list.sh #!/bin/bash #Use for loop deal with list. #2013.12.20 I=1 for LOOP in 1 2 3 4 5 6 do echo "loop:"$I echo "LOOP="$LOOP I=`expr $I + 1` done exit 0
[root@localhost shell]# cat use_for_deal_with_array.sh #!/bin/bash #Use for loop deal with array. #2013.12.20 I=1 ARR=(1 2 3 4 5 6) for LOOP in ${ARR[*]} do echo "loop:"$I echo "LOOP="$LOOP I=`expr $I + 1` done exit 0