LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software
User Name
Password
Linux - Software This forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.

Notices


Reply
  Search this Thread
Old 11-07-2006, 01:20 AM   #1
bajaj111
LQ Newbie
 
Registered: Nov 2006
Posts: 8

Rep: Reputation: 0
saving a file after SED


when i run the sed , it replaces the text but it doesnot save that edited file, how can i replace the existing file with the edited file using sed
 
Old 11-07-2006, 02:47 AM   #2
bathory
LQ Guru
 
Registered: Jun 2004
Location: Piraeus
Distribution: Slackware
Posts: 13,163
Blog Entries: 1

Rep: Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032
You should redirect the output to a temp file and then ovewrite original file with the temp one:
Code:
sed '/blah/blah' file > tempfile
mv tempfile file
 
Old 11-07-2006, 02:50 AM   #3
theYinYeti
Senior Member
 
Registered: Jul 2004
Location: France
Distribution: Arch Linux
Posts: 1,897

Rep: Reputation: 66
Use sed's -i flag. Be careful, there's no way back.

Yves.
 
Old 11-07-2006, 10:32 AM   #4
soggycornflake
Member
 
Registered: May 2006
Location: England
Distribution: Slackware 10.2, Slamd64
Posts: 249

Rep: Reputation: 31
Quote:
Originally Posted by theYinYeti
Use sed's -i flag. Be careful, there's no way back.

Yves.
You can supply a suffix to -i which will cause a backup to be created (with GNU sed at least).
 
  


Reply



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



Similar Threads
Thread Thread Starter Forum Replies Last Post
filesize limit on 'cat $file | sed > $file' drkstr Linux - Software 2 07-10-2006 02:47 AM
saving file blackzone Programming 5 01-21-2005 05:51 PM
saving file darkangel29 Linux - Newbie 2 11-25-2004 01:16 PM
Saving as a file in C++ dfownz Programming 3 07-03-2004 08:39 AM
saving files after sed processing raypen Linux - General 2 07-23-2002 06:38 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Software

All times are GMT -5. The time now is 06:52 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration