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
i am stuck on array part from getting response of jquery. anyone could help?

Object-oriented programming paradigm Object  Oriented  Programming  is  an  aproach  in  which  a  program  is  viewed  as  a  dynamic  network  of collaborating objects, where

Your task will be to code a simulation of image compression based on the approximate low rank structure of the set of image patches. You will write functions .code = my block compr

Of the 6,325 kindergarten students who participated in the study, almost half or 3,052 were eligible for a free lunch program. The categorical variable sesk (1 == free lunch, 2 = n


Write a Perl program that uses a hash structure. The program should use a larger number of operations (100 or more) on this hash. To do that, use a random number generator to creat

I am working on a game project using C# XNA. I only have two weeks from the deadline. Would you help me to finish it up? Please let me know as soon as possible. Thanks, Sophi

I need a program that writes the first column of the matrix. The numbers in this column follow the pattern below: 1. Numbers start at 1 and count up to ''nels'' in increments of

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

I need help with having a user input a year, and my program to spit out what day of the week Christmas is on.... any helping hands on this?