首页 > 代码库 > while

while

while

    适用于循环次数未知

语法:

   while conditions;do

     statement

     ……

   done


练习

   #!/bin/bash

   #

   who | grep ‘username‘ > /dev/null

   while [ $? != 0 ] ;do

     sleep 5

     echo `date +T`

     who  | grep ‘username‘ > /dev/null

   done

   echo "username is login"

while