浏览量 4879
2014/02/03 01:35
#!/bin/bash
s=asffsdAd32DSsdi@#!\$fihiZFSF87768Z
a=0
A=0
b=0
length=`echo ${#s}`
for((i=0;i<$length;i++))
do
e=`echo ${s:$i:1}`
if [[ $e = [[:lower:]] ]]
then
a=$[ $a+1 ]
elif [[ $e = [[:upper:]] ]]
then
A=$[ $A+1 ]
else
b=$[ $b+1 ]
fi
done
echo "a-z" have nuber: $a
echo "A-Z" have number: $A
echo "Other" have number: $b
[root@wangzi test]# sh charat
a-z have nuber: 14
A-Z have number: 8
Other have number: 11
上一篇 搜索 下一篇