Shell脚本笔记3-循环
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
郑重声明:本站内容如果来自互联网及其他传播媒体,其版权均属原媒体及文章作者所有。转载目的在于传递更多信息及用于网络分享,并不代表本站赞同其观点和对其真实性负责,也不构成任何其他建议。