judge_data_type.sh 

#!/bin/bash

read -p "Please input one character:" key
case $key in
  [a-z]|[A-Z])
     echo "alphabet"
     ;;
  [0-9])
     echo "number"
     ;;
     *)
     echo "space、tab or other control character"
     ;;
esac
  • 1.
  • 2.
  • 3.
  • 4.
  • 5.
  • 6.
  • 7.
  • 8.
  • 9.
  • 10.
  • 11.
  • 12.
  • 13.
  • 14.

验证:

[root@logstash ~]# sh judge_data_type.sh 
Please input one character:a
alphabet
[root@logstash ~]# sh judge_data_type.sh 
Please input one character:3
number
[root@logstash ~]# sh judge_data_type.sh 
Please input one character:	
space、tab or other control character
[root@logstash ~]#
  • 1.
  • 2.
  • 3.
  • 4.
  • 5.
  • 6.
  • 7.
  • 8.
  • 9.
  • 10.