Computer Science, asked by jiya3224, 11 months ago

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 SujanDangal
0

it is quite tough question

Answered by Anonymous
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