Custom Search

Tuesday, 8 May 2012

Write a Linux shell script that counts occurrence of a word in file, Unix program that counts occurrence of number of words in file


Write a Linux shell script that counts occurrence of a word in file, Unix program that counts occurrence of number of words in file


Program
clear


echo-n"Emter file name:"
read fn


echo-n"Enter the pattern:"
read pt


c='grep-io$pt$fn|wc-w'
echo" No.of occurrence:"$c


Output:
Enter file name:temp.sh
Enter the pattern: file
No.of occurrence:4
<<< Previous  ||  Current  ||  Next >>>  

No comments:

Post a Comment

Laptops