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
fow to I write a emplate that reads a set of numbers typed at the keyboard into an array of T

Improved Support for JavaScript Debugging ASP.NET has many benefits over vintage ASP in the place of debugging. You can now quickly debug your server-side value using the complete

Question: (a) What do you understand by the term Postback? (b) Describe five benefits of creating virtual directories while developing an ASP.NET application. (c) Exp

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

Assignment for Networing&camunication

On-line fair and ethical share trading system (Olfest) A system is required that allows on-line customers to buy and sell stock market shares in a selection of companies. B

This is Python program I am stuck Modify the Russian peasant multiplication mod n function from class to perform "Russian peasant exponentiation" instead. You can assume that you

Write a detailed description on how you would go about planning information system for an organisation


The assignment has two parts: first you generate a simple application for a MID that operates independently of other MIDs. As a second part, the application is extended to keep so