Write a shell script  that will read a file name and pattern from the command line and check whether that pattern exist in file and if exist then count total no. of words in the lines where pattern found






code:-

echo “enter the file name”
read a
echo “enter the pattern”
read b
grep -n $b $a | wc -w

output:-
enter the file name 
file1
enter the pattern
unix
1


Post a Comment

If you have any doubts, Please let me know
Thanks!

Previous Post Next Post