If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > Data Access, Manipulation & Batch Languages > Unix Shell Scripts > Deleting a part of the line based on patterns

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 06-09-04, 09:04
yahoo yahoo is offline
Registered User
 
Join Date: Jun 2004
Posts: 6
Deleting a part of the line based on patterns

Hi,

I need to do something as below:

george, john, mckay delete all here

everything from delete should be deleted, the out put should be,

george, john, mckay

Any help appreciated.

Thanks
Reply With Quote
  #2 (permalink)  
Old 06-09-04, 09:10
vgersh99 vgersh99 is offline
Registered User
 
Join Date: Apr 2004
Location: Boston, MA
Posts: 325
echo 'george, john, mckay delete all here' | sed -e 's/\(.*\) delete .*/\1/g'
Reply With Quote
  #3 (permalink)  
Old 06-10-04, 05:13
yahoo yahoo is offline
Registered User
 
Join Date: Jun 2004
Posts: 6
Thumbs up

This works perfectly...I am too weak at shell script could you help me with another problem...

I have a file like below:

gina, crab.george, john, joe, crab.mckay

Get rid of the 'crab.' and sort the rest of the output. I expect the output to be like:

george, gina, joe, john, mckay

Thanks for all your help.
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

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 Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On