#!/bin/bash
str="zs123"
for ((i=1;i<=3;i++));do
read -p "请输入第$i次密码:" sc
if [ $sc ]; then #判断sc是否为空
if [ $sc = $str ];then #判断2个字符串是否相同
echo "密码输入正确"; break
fi
else
echo "密码输入错误,第$i次。"
fi
done
Judge whether the password is correct for 3 times
Guess you like
Origin blog.51cto.com/12723336/2588362
Ranking