while
while
死循环语句可以用来观察内存变化 while后面要加:
0.5秒更新一次内存
[[email protected] test]# cat 7.sh
while :
do
free
sleep 0.5
clear
done
[[email protected] test]#
echo -e能识别\n这样代表回车符的字符表达
[[email protected] test]# cat 7.sh
#!/bin/bash
var1="AAA"
var2="BBB"
var3="CCC"
while :
do
clear
echo -e "A:${var1}\nB:${var2}\nC:${var3}"
temp=$var1
var1=$var2
var2=$var3
var3=$temp
sleep 1
done
[[email protected] test]#
输出1到10
[[email protected] test]# cat 8.sh
#!/bin/bash
count=1
while (( $count <= 10 ))
do
echo $count
((count++))
done
[[email protected] test]#
如果输入密码正确,就显示================,否则提示错误
[[email protected] test]# cat 9.sh
while :
do
read -p 'your name:' name
read -p 'passwd:' psd
if [ $name = 'root' -a $psd = '12345678' ]
then
echo 'login successful ,welcome da SB'
# exit
break
else
echo 'error'
fi
done
echo '=================='
[[email protected] test]#