until循环
条件不满足进循环,条件满足时退出。
until CONDITION;do
statement
...
done
例如:
1.写一个脚本,将输入的内容小写改成大写。
#!/bin/bash
read -p "input someting" STR
until [ $STR == ‘quit‘];do
echo $STR|tr ‘a-z‘ ‘A-Z‘
done
2.写一个脚本,每隔5秒检测hadoop用户是否登陆。
#!/bin/bash
who|grep ‘hadoop‘ &> /dev/null
LOG=$?
until [ $LOG -eq 0 ];do
echo `date hadoop is not login`
sleep 5
who|grep ‘hadoop‘ &> /dev/null
LOG=$?
done
echo ‘date hadoop is login‘
本文出自 “小私的blog” 博客,请务必保留此出处http://ggvylf.blog.51cto.com/784661/1608091
原文地址:http://ggvylf.blog.51cto.com/784661/1608091