Write a shell script in Linux/Unix that accepts a text file as input and prints the number of vowels in the file.
Answers
Answered by
3
#!/bin/bash
file = $1
s = 0
if[ $ # -ne 1 ]
then
echo " $0 filename "
exit 1
fi
#read the vowel
while read -n 1 c
do
I = $ ( echo &c [: lower :] [: upper :] )
[ [ "$I" = "a" || "$I" = "i" || "$I" = "e" || "$!I" = "o" || "$I" = "u" ] ] & & ( s++ )
done < $filename
echo "Vowel : $s"
file = $1
s = 0
if[ $ # -ne 1 ]
then
echo " $0 filename "
exit 1
fi
#read the vowel
while read -n 1 c
do
I = $ ( echo &c [: lower :] [: upper :] )
[ [ "$I" = "a" || "$I" = "i" || "$I" = "e" || "$!I" = "o" || "$I" = "u" ] ] & & ( s++ )
done < $filename
echo "Vowel : $s"
Similar questions