1、
[root@centos7pc1 test2]# ls test.sh [root@centos7pc1 test2]# cat test.sh ## 测试脚本 #!/bin/bash read -p "please input an number or an letter: " KEY case $KEY in [a-z]|[A-Z]) echo "You had entered an letter!" ;; [0-9]) echo "You had entered a number!" ;; *) echo "You had entered an abnormal character!" esac [root@centos7pc1 test2]# bash test.sh ## 测试数字 please input an number or an letter: 6 You had entered a number! [root@centos7pc1 test2]# bash test.sh ## 测试字母 please input an number or an letter: U You had entered an letter! [root@centos7pc1 test2]# bash test.sh ## 测试其他字符 please input an number or an letter: ! You had entered an abnormal character!