![]() |
|
|
|
|
|||||||
| Forums | Portal | Register | Forum Rules | FAQ | Contribute | Members List | Arcade | Search | Today's Posts | Mark Forums Read |
| 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 !! |
|
|
Submit Tools | LinkBack | Thread Tools | Search this Thread | Display Modes |
|
#1
|
|||
|
|||
|
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! |
| Forum Sponsor | ||
|
|
|
#2
|
||||
|
||||
|
Code:
sed -e 's_^\([^ ]+[ ]+[^ ]+[ ]+[^ ]+\).*_\1_' [ ]+ 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. |
|
#3
|
|||
|
|||
|
Plz Clarify
Dear Reborg,
would u plz explain, what exactly is happening in the sequence. |
|
#4
|
||||
|
||||
|
see added comments above.
|
||||
| Google The UNIX and Linux Forums |