Write an awk script to count the number of lines in a file that do not contain vowels
Answers
Write a shell script that deletes all lines containing a specified word ... Exercise 08: Write an awk script to find the number of lines in a file that do not contain vowels i or o.
echo "Enter your file name:"
read file
cnt=0
awk '$0!~/[aeiou]/{ cnt++ }
END{printf "The number of lines that does not contain vowels are: %d\n",count}' $f
The below are the step by step explanation of the program
First the program seeks the input from the user which is nothing but the file from which the count of number of line without containing vowels needs to be given.
The program reads the file, initialize a variable called “cnt” to act as a counter and then checks through “awk” script whether the read lines contains vowel or not. If the lines does not contains vowel then the count is incremented. Finally the count is printed.