The UNIX and Linux Forums  
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.

Go Back   The UNIX and Linux Forums > Special Forums > UNIX Desktop for Dummies Questions & Answers
.
google unix.com



UNIX Desktop for Dummies Questions & Answers Discuss UNIX and Linux user interfaces like GNOME, KDE, CDE, and Open Office 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 specific line ryandegreat25 Shell Programming and Scripting 6 07-21-2009 04:46 AM
Deleting Characters at specific position in a line if the line is certain length Cailet Shell Programming and Scripting 10 12-17-2008 02:41 PM
retrieving specific lines from a file - can I use grep ? hcclnoodles Shell Programming and Scripting 9 09-23-2008 06:45 AM
grep a word from a specific line blurboy Shell Programming and Scripting 3 01-23-2008 04:13 AM
check position of end of line for some specific lines senthil_is Shell Programming and Scripting 1 11-09-2007 01:19 AM

Reply
English Japanese Spanish French German Portuguese Italian Dutch Swedish Russian Norwegian Hungarian Hebrew Danish Powered by Powered by Google
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
  #1 (permalink)  
Old 09-11-2009
Chthonic Chthonic is offline
Registered User
  
 

Join Date: Apr 2009
Posts: 4
grep lines with two specific characters somewhere in the line

I'm having trouble with extracting certain lines from a file based on whether they have all the required fields.

Original file:
Code:
snt:594:Sam N This
bpt:2342:Bob P That
lr:123
wrp:23:Whoever Person
cor:794
Desired output:
Code:
snt:594:Sam N This
bpt:2342:Bob P That
wrp:23:Whoever Person
I've searched and I haven't been able to find anything to target only these lines. The only thing I can think of is this but it doesn't work:
Code:
grep ":*:" < temp

Last edited by vgersh99; 09-11-2009 at 12:24 PM.. Reason: code tags, PLEASE!
  #2 (permalink)  
Old 09-11-2009
vgersh99's Avatar
vgersh99 vgersh99 is online now Forum Staff  
Moderator
  
 

Join Date: Feb 2005
Location: Boston, MA
Posts: 5,119
Code:
grep '.*:.*:.*' myFile
OR
nawk -F: 'NF==3' myFile
  #3 (permalink)  
Old 09-11-2009
Chthonic Chthonic is offline
Registered User
  
 

Join Date: Apr 2009
Posts: 4
That's exactly what I was looking for. Thanks!
  #4 (permalink)  
Old 09-11-2009
thegeek thegeek is offline
Registered User
  
 

Join Date: Apr 2009
Location: /usr/bin/vim
Posts: 436
To understand it better, you are missing . (dot) thats all. Previously you had :* which meant zero or more :.

Code:
 grep ":.*:" t1
The above will also work, if the input you had given is as similar as you had given in your 1st post.
Sponsored Links
Reply

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:52 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