For 循环

for 循环语法

for var in item1 item2 ... itemN
do
    command......
done

示例 :

#!/bin/sh
for loop in 1 2 3 
do
    echo "The value is: $loop"
done

遍历数组

#!/bin/sh
arr=(1 2 3)

for i in "${!arr[@]}";   
do   
    printf "%s\t%s\n" "$i" "${arr[$i]}"  
done