#!/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
时间: 2024-10-03 09:41:16