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
Grep help flood Shell Programming and Scripting 3 06-05-2008 10:14 PM
Grep Aejaz UNIX for Advanced & Expert Users 3 04-30-2008 04:10 AM
grep dineshr85 Shell Programming and Scripting 1 10-10-2007 01:52 AM
how to exclude the GREP command from GREP yamsin789 UNIX for Advanced & Expert Users 2 10-04-2007 11:59 PM
Make grep -c display like grep -n? Jerrad Shell Programming and Scripting 2 08-24-2006 09:20 PM

Closed Thread
 
Submit Tools LinkBack Thread Tools Display Modes
  #1  
Old 10-10-2001
sskb
Guest
 

Posts: n/a
Question grep

I have to find some lines in a file which contain a particular character twice.

for example,

if the repeating character is ':' and the file is like...

abc:fgh
afg:rfg jhk:ret <-- this line is needed.
mmv:wre

how can i do this?

Forum Sponsor
  #2  
Old 10-10-2001
Registered User
 

Join Date: Jul 2001
Location: Chicago, IL
Posts: 8
Double grep

Hello, how are you doing? I believe that I have the answer to your question, provided that there is a space separation between the two entities containing the colons (. If this IS the case, then the following command can be used:

pg FILE_NAME | grep : | grep ' '

This will then display any line containing the colon and that also has a space and another colon. Hence, for your example, only the second line will be displayed.

In the meantime, I will be thinking of a more slick way to search for such lines. Take care.

JHeliosfear
  #3  
Old 10-10-2001
sskb
Guest
 

Posts: n/a
for the particular requirement.. it works fine. but when i go for something more.. it fails. can i have an exact remedy for the problem?

  #4  
Old 10-10-2001
Perderabo's Avatar
Unix Daemon
 

Join Date: Aug 2001
Location: Washington DC Area
Posts: 8,614
Try:
grep '\:[^:]*\:' filename
  #5  
Old 10-10-2001
sskb
Guest
 

Posts: n/a
thanks,
that works good.
Google The UNIX and Linux Forums
Closed Thread

Thread Tools
Display Modes




All times are GMT -7. The time now is 12:20 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