LinuxQuestions.org
LinuxAnswers - the LQ Linux tutorial section.
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, 02: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, 03:47 AM   #2
bathory
Guru
 
Registered: Jun 2004
Location: Piraeus
Distribution: Slackware
Posts: 10,973

Rep: Reputation: 1343Reputation: 1343Reputation: 1343Reputation: 1343Reputation: 1343Reputation: 1343Reputation: 1343Reputation: 1343Reputation: 1343Reputation: 1343
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, 03:50 AM   #3
theYinYeti
Senior Member
 
Registered: Jul 2004
Location: France
Distribution: Arch Linux
Posts: 1,897

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

Yves.
 
Old 11-07-2006, 11: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


Thread Tools Search this Thread
Search this Thread:

Advanced Search

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 03:47 AM
saving file blackzone Programming 5 01-21-2005 06:51 PM
saving file darkangel29 Linux - Newbie 2 11-25-2004 02:16 PM
Saving as a file in C++ dfownz Programming 3 07-03-2004 09:39 AM
saving files after sed processing raypen Linux - General 2 07-23-2002 07:38 AM


All times are GMT -5. The time now is 08:53 AM.

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
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration