The UNIX and Linux Forums  

Go Back   The UNIX and Linux Forums > Top Forums > UNIX for Dummies Questions & Answers
Google UNIX.COM


UNIX for Dummies Questions & Answers If you're not sure where to post a UNIX or Linux question, post it here. All UNIX and Linux newbies welcome !!

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
Counting the number of occurances of all characters (a-z) in a string rsendhilmani Shell Programming and Scripting 5 08-05-2008 09:10 AM
problem with grep on search string in a txt file over multiple files m00 UNIX for Dummies Questions & Answers 2 05-18-2008 11:21 AM
how to search string and number in one file and check in the other file knshree Shell Programming and Scripting 9 08-24-2007 01:29 AM
Counting number of files in a directory iamalex UNIX for Dummies Questions & Answers 2 09-05-2005 07:13 AM
Count number of files in subdirectories cbeverly UNIX for Dummies Questions & Answers 2 06-02-2005 12:06 PM

Reply
 
Submit Tools LinkBack Thread Tools Display Modes
  #1  
Old 08-11-2007
Registered User
 

Join Date: Aug 2007
Posts: 12
count the number of files which have a search string, but counting the file only once

I need to count the number of files which have a search string, but counting the file only once

if search string is found.

eg: File1: Please note that there are 2 occurances of "aaa"

aaa
bbb
ccc
aaa

File2: Please note that there are 3 occurances of "aaa"

aaa
bbb
ccc
aaa
aaa

File3:
bbb
ccc

But need the count of files which has the occurance of "aaa". In the above example, it should
give me 2 --> (File1 and File2).

It should not give me 5 since "aaa" occured 2 times in File1 and occured 3 times in File2.
Reply With Quote
Forum Sponsor
  #2  
Old 08-11-2007
reborg's Avatar
Administrator
 

Join Date: Mar 2005
Location: Ireland
Posts: 3,592
Code:
egrep -l aaa file1 file2 file 3  | wc -l
Reply With Quote
Google The UNIX and Linux Forums
Reply

Thread Tools
Display Modes




All times are GMT -7. The time now is 02:03 PM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited.
The UNIX and Linux Forums Content Copyright ©1993-2008. All Rights Reserved.Ad Management by RedTyger Visit The Complex Event Processing Blog

Content Relevant URLs by vBSEO 3.2.0