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
1. Logon to Linux. 2. Create a directory "Unix" under your home directory. Command(s): …………………………………………. 3. Create four sub-directories bin, conf, docs

P4's goal is to design the C# classes needed to track creature viability in a MMO game under development .  Part I: Class design 1)  GameCreature class (with derived ty

Example problem Imagine that  you  require  to create  a robot  that  will  roll up  close to a light  lamp  and  stop  a fixed distance from it.  The first question is, how w

Support for Multi-Targeting The multi-targeting function of Vision Facilities allows you specify the particular edition or account of the .NET Structure that is required for your p

What is an algorithm? What are the characteristics of a good algorithm? An algorithm is defined as “a step-by-step procedure of accomplishing some task'''' An algorithm may be sh

Question: (a) How do you implement the following in ASP.NET: (i) Server-side Comments (ii) Server-side Include Directives. (b) What is the purpose of a HashTable? (

We are looking for Pool Services Software Our company Pool Hands LLC is looking to build software for our internal use. We would like the software built therefore that it could

OOPS Concepts Object-oriented programming (OOP) is a computer science term used to characterize a programming language that began development in the 1960’s. The term ‘object-orient

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

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