条件不满足进循环,条件满足时退出。
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‘
时间: 2024-10-05 04:58:08