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
help for search or grep in a file pvr_satya Shell Programming and Scripting 2 08-04-2008 03:04 PM
how to search -n in a file with grep lamilami Shell Programming and Scripting 2 11-28-2007 04:42 PM
recrusive search in GREP arunkumar_mca UNIX for Dummies Questions & Answers 8 11-16-2006 09:49 PM
multiple search with grep amon Shell Programming and Scripting 5 04-04-2006 07:53 AM
grep - speed of search davirime UNIX for Dummies Questions & Answers 1 09-25-2002 10:26 AM

Closed Thread
English Japanese Spanish French German Portuguese Italian Dutch Swedish Russian Norwegian Hungarian Hebrew Danish Bulgarian Greek Powered by Powered by Google
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
  #1 (permalink)  
Old 11-14-2008
shubhranshu shubhranshu is offline
Registered User
  
 

Join Date: Sep 2008
Posts: 21
Distinct search usisng GREP cmd

Hi All,

I have the following problem where I have been trying but not able to resolve it:-

I have a file which has some thousands entries.
For eg:-
The content of the file is :-
==============================================

./admin.cpp:9:#include "framework/RegistryContext.h"
./admin.cpp:10:#include "framework/LoggingContext.h"
./adminbatchbase.h:10:#include"framework/RegistryInterface.h"
./adminbatchbase.h:11:#include"framework/LoggingInterface.h"
./adminbatchbase.h:12:#include"framework/BatchException.h"

===============================================

Now if I count the number of occurences of "framework" then it comes to 5(wc -l)
But I want the count to be 2 as there are only 2 distinct files where framework is there.

Could somebdy help me with this?

Thanks,
SD.
  #2 (permalink)  
Old 11-14-2008
sriharsha_kvr sriharsha_kvr is offline
Registered User
  
 

Join Date: Nov 2008
Location: Bangalore
Posts: 11
Sorry....The below code will not work as per the requirement

Try using -w option with grep. If you want the search to be extended in multiple files, try the following command

find . 2>/dev/null | xargs grep -w "string" 2>/dev/null

Last edited by sriharsha_kvr; 11-14-2008 at 05:27 AM.. Reason: Requirement wrongly understood
  #3 (permalink)  
Old 11-14-2008
sriharsha_kvr sriharsha_kvr is offline
Registered User
  
 

Join Date: Nov 2008
Location: Bangalore
Posts: 11
This should work

find . 2>/dev/null | xargs grep -w framework | cut -d ":" -f1 | uniq -d
Closed Thread

Bookmarks

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On




All times are GMT -4. The time now is 05:55 AM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited. Language Translations Powered by .
vBCredits v1.4 Copyright ©2007 - 2008, PixelFX Studios
The UNIX and Linux Forums Content Copyright ©1993-2009. All Rights Reserved.Ad Management by RedTyger

Content Relevant URLs by vBSEO 3.2.0