برنامه ای برای شمارش حروف صدا دار

Program :- To count number of vowels.

echo Enter a string
read str
nc=`expr $str | wc -c`
i=1
n=0
while [ $i -le $nc ]
do
ch=`echo $str | cut -c $i`
case $ch in
[aeiouAEIOU])
n=`expr $n + 1`;;
esac
i=`expr $i + 1`
done
echo Number of vowels is : $n

خروجی برنامه

Enter a string
gopinath

Number of vowels is : 3