Sunday 10 August 2014

Write a shell script that accept a list of filenames as its argument, count and report occurrence of each word that is present in the first argument file on other argument files.


if [ $# -ne 2 ]
then
echo "Error :invalid no of arguments "
exit
fi
str=`cat $1 | tr '\n' ' '`
for a in $str
do
echo "word=$a , count=`grep -c "$a" $2` "
done

0 comments:

Post a Comment

 
- |