1. #!/bin/bash
    2. #循环测试用户的账户名和密码,最大测试 3 次,输入正确提示登录成功,否则提示登录失败
    3. #用户名为 tom 并且密码为 123456
    4. for i in {1..3}
    5. do
    6. read -p "请输入用户名:" user
    7. read -p "请输入密码:" pass
    8. if [ "$user" == 'tom' -a "$pass" == '123456' ];then
    9. echo "Login successful"
    10. exit
    11. fi
    12. done
    13. echo "Login Failed"