W.A.S.S to count the number of files which contains a given pattern and also display the names of all those files.
echo -e "Enter the pattern : \c"
for i in `ls -1`
if [ -f $i ]
l=`grep -E $ptrn $i|wc -l`
if [ $l -gt 0 ]
echo "$ptrn is found in $i file."
cnt=`expr $cnt + 1`
echo "$ptrn is found in Total $cnt file(s)."
Enter the pattern : narendra
narendra is found in temp3.txt file.
narendra is found in temp4.txt file.
narendra is found in Total 2 file(s).