Shell脚本测试密码 Shell 脚本测试用户密码长度,包括密码长度,是否包含大小写字母,特殊符号。 #!/bin/bash #输入密码 read -p "input a pass: " ps #密码长度大于7且包含小写字母,大写字母,特殊符号 if [ ${#ps} -gt 7 ] && [[ $ps =~ [a-z] ]] && [[ ${ps} =~ [A-Z] ]] && [[ ${ps} =~ [@!_] ]] then echo "yes" #符合要求输出yes else echo "no" #不符合要求输出no fi