for 列表形式
for variable in {list} do statement done for var in 1 2 3 4 do echo $var done for var in {1..4} do echo $var done for var in {start..end..step} do statement done for i in {1..100..2} do echo $i done for file in $(ls) do echo $file done for file in * do echo $file done
类c风格的for循环
for ((expression1;expression2;expression3)) do statement done for ((i=0;i<5;i++) do echo $i done
for循环处理数组
for variable in ${array[*]} do statement done array={1 2 3 4 5} for num in ${array[*]} do echo $num done
时间: 2024-10-11 02:45:04