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"

时间: 2024-10-10 17:43:51