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"
本文共 264 字,大约阅读时间需要 1 分钟。
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"
转载于:https://blog.51cto.com/jiaoxianyao/1913533