工作环境:Red Hat Enterprise Linux Server release 6.5 (Santiago) 、 bash
#!/bin/bash
#
[ "$1" == "" ] && echo "语法错误"
[[ "$1" =~ ^[0-9] ]] && echo "数字开头"
[[ "$1" =~ ^[a-zA-Z] ]] && echo "字母开头"
#!/bin/bash
#
read -p "input password:" pass
#a="`echo $pass`"
[[ "${#pass}" -ge 5 && "${#pass}" -le 8 ]] && echo "OK" || echo "NO"
if [[ "${#pass}" -gt 8 ]];then
end=`echo $pass | cut -c 1-8`
echo $end
fi
注意:=~的意思是开启正则表达式