一段用来验证密码的shell
通过这个简单的验证密码的shell脚本,来熟悉下while和if的用法,也许对您有点用处,当然还有更多的实现方法,比如用until什么的
#!/bin/sh
# hao32 repasswd
while [ -z $pass1 ] || [ -z $pass2 ] || [ $pass1 != $pass2 ]
do
read -p "Please type your passwd :" pass1
read -p "Please conform your passwd :" pass2
if [ -z $pass1 ]; then
echo "passwd should not be empty!"
elif [ $pass1 != $pass2 ]; then
echo "passwd not match! retype again!"
fi
done
echo "Ok, you passed"
阅读(1223) | 评论(0) | 转发(0) |