四时宝库

程序员的知识宝库

shell脚本之1分钟就能吃透while循环

来一个小果子吃吃

while 条件

do

执行语句

done

#!/bin/bash
i=1
while (($i < 6))
do
        echo "--->  $i"
        let "i++"
done

搞一个中果子吃吃

运行脚本以后,会不断的读取输入的数据

#!/bin/bash
echo "exit---> ctrl-D"
while read FILM
do
        echo "it is a $FILM"
done

也可以死循环

while true

do 循环语句

done

发表评论:

控制面板
您好,欢迎到访网站!
  查看权限
网站分类
最新留言
    友情链接