一、for语句的基本格式
二、使用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
本文章为转载内容,我们尊重原作者对文章享有的著作权。如有内容错误或侵权问题,欢迎原作者联系我们进行内容更正或删除文章。