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

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
Search and replace jobbyjoseph Shell Programming and Scripting 12 02-06-2008 10:33 PM
Perl: Search for string on line then search and replace text Crypto Shell Programming and Scripting 4 01-04-2008 06:24 AM
SED Search and Replace Question for Google Analytics Neo Shell Programming and Scripting 11 08-07-2007 03:32 PM
search and replace tungaw2004 Shell Programming and Scripting 1 03-23-2007 07:59 PM
sed search and replace d__browne UNIX for Dummies Questions & Answers 7 04-26-2006 06:46 AM

Reply
 
Submit Tools LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 06-20-2006
Registered User
 

Join Date: Dec 2004
Posts: 15
search and replace one more question

Hi,

I have a file that contains the following contents:

14:05 apple
orange123
456mango
16:45 banana

I wanted to replace ONLY the "14:05 " and "16:45" with nothing and trying to use the following syntax

sed -e 's/[0-9][0-9]*//g' -e 's/^: //g' my_file > new_temp
cat new_temp
apple
orange
mango
banana


I only wanted to replace the "14:05 " and "16:45" and do not want to change the name of orange123 and 456mango while
the above command has changed the file name as well.

Can someone correct my syntax.

I apprecaite you help in advance

Regards,
Ghazi
Reply With Quote
Forum Sponsor
  #2 (permalink)  
Old 06-20-2006
vgersh99's Avatar
Moderator
 

Join Date: Feb 2005
Location: Boston, MA
Posts: 3,002
Code:
sed 's/^[0-9][0-9]:[0-9][0-9] //' myFile
Reply With Quote
  #3 (permalink)  
Old 06-20-2006
Registered User
 

Join Date: Dec 2004
Posts: 15
Thanks a lot.
Reply With Quote
Google The UNIX and Linux Forums
Reply

Thread Tools
Display Modes




All times are GMT -7. The time now is 09:06 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 Global Fact Book

Content Relevant URLs by vBSEO 3.2.0