Write a shell script in linux/unix that accepts a text file as input and prints the number of words in the file which do not have a vowel.
Answers
Answered by
0
it is quite tough question
Answered by
3
Hey Bebes
Here Is Your Answer
#!/bin/bash
file=$1
v=0
if [ $# -ne 1 ]
then
echo "$0 fileName"
exit 1
fi
if [ ! -f $file ]
then
echo "$file not a file"
exit 2
fi
while read -n 1 c
do
l=$(echo $c | tr [:upper:] [:lower:])
[[ "$l" == "a" || "$l" == "e" || "$l" == "i" || "$l" == "o" || "$l" == "u" ]] && (( v++ ))
done < $file
echo "Vowels : $v"
echo "Characters : $(cat $file | wc -c)"
echo "Blank lines : $(grep -c '^$' $file)"
echo "Lines : $(cat $file|wc -l )"
Hope its helps
#Baba
Attachments:
Similar questions
History,
7 months ago
Computer Science,
7 months ago
Math,
7 months ago
Computer Science,
1 year ago
Computer Science,
1 year ago
Math,
1 year ago
Math,
1 year ago
English,
1 year ago