English Deutsch Français Italiano Español Português 繁體中文 Bahasa Indonesia Tiếng Việt ภาษาไทย
All categories

3 answers

I can tell you the logic. Try testing as I do not have a Unix box right now with me to check.

read word
lengthofword=`echo $word | wc -c`
cntr=1
no_of_vowels=0
while($cntr -le $lengthofword)
do
{
ltr=`cat $word | cut -c$cntr`
if [ $ltr = "a" -o $ltr = "e" .... $ltr = "u" ]
then
no_of_vowels=`expr $no_of_vowels + 1 `
cntr=`expr $cntr + 1 `
}
done

2006-11-14 23:21:03 · answer #1 · answered by Subhasis G 4 · 0 1

Shell Script Count

2016-12-18 06:24:40 · answer #2 · answered by Anonymous · 0 0

it would be a simple one liner

vowel_no= cat file.txt | tr -cd \aeiou\ | wc -c
echo $vowel_no

cat file.txt prints the file out which is piped the the translate command which deletes all the everything else other than the vowels (this is done by the complement c) and the output of this is piped to wc -c does a character count

2006-11-15 02:43:28 · answer #3 · answered by life goes on... 2 · 0 0

fedest.com, questions and answers