#!/bin/bash
echo "while 方法!"
echo "请输入登录用户名:"
read name1
if test $name1 = "yang"
then
echo "登录成功"
else
echo "登录失败,请输入正确的用户名:"
read name1
while [ $name1 != "yang" ]
do
echo "登录失败,请输入正确的用户名:"
read name1
if test $name1 = "yang"
then
echo "登录成功"
break;
fi
done
fi
echo "until 方法!"
echo "请输入登录用户名:"
read name1
if test $name1 = "yang"
then
echo "登录成功"
else
until [ $name1 == "yang" ]
do
echo "登录失败,请输入正确的用户名:"
read name1
if test $name1 = "yang"
then
echo "登录成功"
break;
fi
done
fi
exit 0
echo "while 方法!"
echo "请输入登录用户名:"
read name1
if test $name1 = "yang"
then
echo "登录成功"
else
echo "登录失败,请输入正确的用户名:"
read name1
while [ $name1 != "yang" ]
do
echo "登录失败,请输入正确的用户名:"
read name1
if test $name1 = "yang"
then
echo "登录成功"
break;
fi
done
fi
echo "until 方法!"
echo "请输入登录用户名:"
read name1
if test $name1 = "yang"
then
echo "登录成功"
else
until [ $name1 == "yang" ]
do
echo "登录失败,请输入正确的用户名:"
read name1
if test $name1 = "yang"
then
echo "登录成功"
break;
fi
done
fi
exit 0
来自 “ ITPUB博客 ” ,链接:http://blog.itpub.net/22664653/viewspace-689436/,如需转载,请注明出处,否则将追究法律责任。
转载于:http://blog.itpub.net/22664653/viewspace-689436/