Only three chances to determine whether the password is correct

#!/bin/bash
str=wgw
for ((i=1;i<=3;i++))
do
read -p "请输入密码: " nb
    if [ ${nb}a = ${str}a ];then
            echo "密码输入正确"
            break
    else
            echo "密码输入错误。第$i次机会"
    fi
done

Guess you like

Origin blog.51cto.com/15077398/2588388