linux命令:until循环
??
until命令簡介:
? ? ? ? until循環:適用于循環次數未知的場景,且條件不滿足就進行循環,條件滿足則退出。
1.命令格式:
語法:
? ? ?until CONDITION; do
? ? ? ? ?statement
? ? ? ? ? ...
? ? ? done
2.命令功能:
?until循環:適用于循環次數未知的場景,且條件不滿足就進行循環,條件滿足則不循環退出。
3.命令參數:
?until? CONDITION; do ? ? ? ?condition:進入循環的條件
? ? ? ? ?statement
? ? ? ? ? ...
? ? ? done
4.命令實例:
? ?1、查看用戶是否登錄,使用until循環體
[root@xuelinux tmp]# vim until1.sh
#!/bin/bash
#program:
#使用until循環體查看用戶是否在線
#history donggen ?2016-11-07-17:20
PATH=/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin:/usr/local/sbin:~/bash
export PATH
until who | grep "donggen" &> /dev/null; do
? ? echo "donggen is not exist."
done
? ? echo "donggen is login."
[root@xuelinux tmp]# chmod +x until1.sh
donggen is not exist.
donggen is not exist.
donggen is not exist.
donggen is not exist.
donggen is login.
本文轉自wang650108151CTO博客,原文鏈接:http://blog.51cto.com/woyaoxuelinux/1870462 ,如需轉載請自行聯系原作者
總結
以上是生活随笔為你收集整理的linux命令:until循环的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 指针与储物箱的关系
- 下一篇: Linux getcwd()的实现【转】