Count no of files, Programming Languages

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"

read ptrn

cnt=0

for i in `ls -1`

do

 if [ -f $i ]

 then

  l=`grep -E $ptrn $i|wc -l`

  if [ $l -gt 0 ]

  then

   echo "$ptrn is found in $i file."

   cnt=`expr $cnt + 1`

  fi

 fi

done

echo "$ptrn is found in Total $cnt file(s)."

 

Output

 

sh filept.sh

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).

Posted Date: 9/26/2012 8:31:22 AM | Location : United States







Related Discussions:- Count no of files, Assignment Help, Ask Question on Count no of files, Get Answer, Expert's Help, Count no of files Discussions

Write discussion on Count no of files
Your posts are moderated
Related Questions
Your solution to the problem should be housed within a while loop, which allows the grader to test your solution repeatedly without having to re-execute the script, as shown in cla

find value of nCr using function

Does anyone know anything about java programming here?

Expertsmind brings you unique solution in java assignments Reflection API Uses of Reflection with java assignment help Reflection is widely used by applications which

I need someone to make an ER diagram.

A large offshore accommodation barge is to be converted into a floating luxury hotel.  It will be connected to a single point mooring buoy (SPM) in a beautiful inland loch where th

Write a function named prob2.m which creates and returns an N×N identity matrix. An identity matrix is a square matrix with values of one on the main diagonal and zeros in all off-

What is an abstract class:   Abstract class is stated as an abstract concept that cannot be instantiated or comparing to interface this can have some implementation and interface c

Normal 0 false false false EN-US X-NONE X-NONE MicrosoftInternetExplorer4

Hi I have an assignment for prolog languagle is it possible to get help