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
Dynamic Binding: - Binding refers to the linking of a procedure call to the code to be executed in response to the call. Dynamic binding (late binding) means that the code associa

Recent problems in finishing implementation: This mobile application is built with Sencha Touch framework. Source code is attached in this zip package. The daily rest calc

Select two different architecture styles to design and implement a software system and provide its Architecture Diagrams (implement the software with java)

How to do socket programming in C

fow to I write a emplate that reads a set of numbers typed at the keyboard into an array of T

i attached the assignment document only i need your help with following three parts: accessible areas, accessible cul-de-sacs that are all connected, entry-exit path with no in

list of 10 operating systems with their hardware specification and also list any 5 software associated with each operating system

Real Distinct and 1 Double Eigenvalue with 1 Eigenvector From the real eigenvalue/vector pair, l 1 and ?h 1 , we find one solution, e l1 t ?h 1 By our work in the 2x

Special Matrices There are some "special" matrices out there which we may use on occasion. The square matrix is the first special matrix.  A square matrix is any matrix that s

We want a program that will allow us to print a "grade list" of the students in a class. The program should loop, asking for a name, midterm score, and final score. It should th