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
Can't alter bootlist mooshkie AIX 2 01-28-2008 07:12 AM
Alter Table Shell Script ankitgupta Shell Programming and Scripting 2 10-06-2006 03:01 AM
To alter perl /bin/date output by - 5 hours Texan Shell Programming and Scripting 2 08-17-2005 05:28 AM
Turning off MMDF permanently QmanV2 UNIX for Dummies Questions & Answers 4 07-07-2003 01:44 PM
Unmounting /home Permanently alfabetman UNIX for Dummies Questions & Answers 8 03-21-2003 07:43 AM

Reply
 
Submit Tools LinkBack Thread Tools Display Modes
  #1  
Old 04-05-2006
Registered User
 

Join Date: Apr 2006
Posts: 22
Question how to alter the old file permanently using sed?

hi ,
m new to sed and awk. can anyone tell me how to alter the old file permanenetly using sed.
e.g.
$sed 's/cat/dog/g' old_file
the above command will replace all the occrance of cat by dog in the file called old_file and by default will show the output at stdout.
so is there anyway of altering the same "old_file" with sed.
plz reply soon,
bye
Reply With Quote
Forum Sponsor
  #2  
Old 04-05-2006
Technorati Master
 

Join Date: Mar 2005
Location: Large scale systems...
Posts: 2,609
possible with -i option of sed
its GNU version of sed

please search the forum
; it had been answered many times
Reply With Quote
  #3  
Old 04-05-2006
Registered User
 

Join Date: Apr 2006
Posts: 22
Thumbs up thanks

thnks buddy,
ya its working.can u also tel me how to remove the header from that same file
i.e.
i did
$ sed -i 's/cat/dog/g' old_file
the above is replacing cat to dog from the file called old_file,can i also remove the 1st line from the same file (old_file) simultaneously?
thanks in advance
Reply With Quote
Google The UNIX and Linux Forums
Reply

Thread Tools
Display Modes




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