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 !!

Reply
 
Submit Tools LinkBack Thread Tools Search this Thread Display Modes
  #1  
Old 06-23-2006
Registered User
 

Join Date: Jan 2006
Posts: 145
Unhappy sed help!

I have the following data:

1 I want to delete this line
2 I want to delete that line

How can I use sed to delete form "to **** line'

my data after shed should be:

1 I want
2 I want

How can I sed start with a letter in the middle of the line and end in that line?

Thanks!
Reply With Quote
Forum Sponsor
  #2  
Old 06-23-2006
reborg's Avatar
Administrator
 

Join Date: Mar 2005
Location: Ireland
Posts: 3,644
Code:
sed -e 's_^\([^ ]+[ ]+[^ ]+[ ]+[^ ]+\).*_\1_'
[^ ]+ match any number > 1 of anything that is not a space
[ ]+ match any number of spaces
.* match every thin else
\( \) copy whatever matches to hold
\1 the contents of the first hold entry

so essentially, I'm telling it to replace the whole line with the first three columns.

Last edited by reborg; 06-27-2006 at 08:58 AM.
Reply With Quote
  #3  
Old 06-27-2006
Registered User
 

Join Date: Jun 2006
Location: Delhi, India
Posts: 6
Plz Clarify

Dear Reborg,
would u plz explain, what exactly is happening in the sequence.
Reply With Quote
  #4  
Old 06-27-2006
reborg's Avatar
Administrator
 

Join Date: Mar 2005
Location: Ireland
Posts: 3,644
see added comments above.
Reply With Quote
Google The UNIX and Linux Forums
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes




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