LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Software (https://www.linuxquestions.org/questions/linux-software-2/)
-   -   saving a file after SED (https://www.linuxquestions.org/questions/linux-software-2/saving-a-file-after-sed-499323/)

bajaj111 11-07-2006 01:20 AM

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

bathory 11-07-2006 02:47 AM

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


theYinYeti 11-07-2006 02:50 AM

Use sed's -i flag. Be careful, there's no way back.

Yves.

soggycornflake 11-07-2006 10:32 AM

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).


All times are GMT -5. The time now is 07:51 PM.