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 > 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
Match a pattern and copy above two lines Danish Shakil Shell Programming and Scripting 16 08-01-2008 02:28 AM
how do i pattern match a field with awk? someone123 Shell Programming and Scripting 4 06-03-2008 09:08 AM
Concatenating multiple lines to one line if match pattern phixsius Shell Programming and Scripting 13 01-24-2008 11:02 PM
SED: match pattern & delete matched lines not4google Shell Programming and Scripting 7 11-22-2006 09:58 AM
How to delete lines do NOT match a pattern JumboGeng UNIX for Dummies Questions & Answers 1 09-20-2006 06:52 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 12-09-2008
fadista fadista is offline
Registered User
  
 

Join Date: Dec 2008
Posts: 13
retrieve lines that match a pattern

Hi,

I would like to know how can I get lines from a text file that match no more than 2 '>'. Example:

Input file:
a >cr1 4 a>b b>c
a >cr2 5 a>b

Output file:
a >cr2 5 a>b


Thanks in advance
  #2 (permalink)  
Old 12-09-2008
zaxxon's Avatar
zaxxon zaxxon is offline Forum Staff  
Moderator
  
 

Join Date: Sep 2007
Location: Germany
Posts: 2,285
Code:
egrep "^[^>]*>[^>]*>[^>]*$"
  #3 (permalink)  
Old 12-10-2008
Franklin52 Franklin52 is offline Forum Staff  
Moderator
  
 

Join Date: Feb 2007
Posts: 4,312
Another approach:

Code:
awk -F ">" 'NF<4' file
Regards
Closed Thread

Bookmarks

Tags
egrep

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 03:21 PM.


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