码迷,mamicode.com
首页 > 系统相关 > 详细

Shell脚本笔记3-循环

时间:2014-11-15 14:10:00      阅读:222      评论:0      收藏:0      [点我收藏+]

标签:blog   io   ar   for   strong   on   2014   art   log   

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





Shell脚本笔记3-循环

标签:blog   io   ar   for   strong   on   2014   art   log   

原文地址:http://blog.csdn.net/zjufirefly/article/details/41145413

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!