Linux Gvim shell for循环

#for循环
#格式
#for 变量 in 列表
#do
#    command1
#    command2
#    ...
#done
#列表是一组值(数字,字符串等)组成的序列,每个值通过空格分隔。每循环一次,就将列表的下一个值赋给变量
#in 列表是可选的,如果不用它,for循环使用命令行的位置参数,如:顺序输出当前列表的数字

1 for loop in 1 2 3 4 5
2 do
3     echo " The value is : ${loop} "
4 done

#顺序输出字符串中的字符,结果为 This is a string

1 for str in ' This is a string '
2 do
3     echo ${str}
4 done

#显示主目录下以 .bash开头的文件

1 for FILE in ${HOME/.bash*}
2 do
3     echo ${FILE}
4 done

 

posted @ 2016-06-09 10:09  Blog4Matto  阅读(195)  评论(0编辑  收藏  举报