#!/bin/bash
read -p "请输入一个字符串:" str
count1=0
count2=0
count3=0
count4=0
num=${#str}
((num--))
for i in $(seq 0 ${num})
do
ch=${str:i:1}
echo -n "$ch"
case $ch in
[0-9])
((count1++))
;;
[A-Z])
((count2++))
;;
[a-z])
((count3++))
;;
*)
((count4++))
esac
done
echo
echo "字符串${str}中有:数字${count1}个,小写字母${count3}个,大写字母${count2}个,其他字符${count4}个"