循环接收用户输入

#! /bin/bash
tryCount=3

while true
do
        read -p "username:" username
        echo "input username is "$username

        if [ "limaoyuan" == $username ]
        then
                echo "输入正确"
                break
        else
                echo "输入错误,还可尝试$tryCount次"
                ((--tryCount))
                if [ $tryCount -le  0 ]
                then
                        break
                fi
                continue
        fi
done

猜你喜欢

转载自shadowsocks.iteye.com/blog/903558