Hi all, Can anyone give me a hint as to why "sed s/word1/word2/g filename" displays the file 'filename' with word2 in place of word1 but the change isn't made permanent? Thanks, Jen
Jenny_Hopkins@toby-churchill.com <Jenny_Hopkins@toby-churchill.com> wrote:
Can anyone give me a hint as to why "sed s/word1/word2/g filename" displays the file 'filename' with word2 in place of word1 but the change isn't made permanent?
By permanent, you mean that filename isn't changed? sed doesn't replace its input files. sed just reads an input stream and puts out an output stream by default. Maybe you can use > to direct the output to a new file and use mv to replace the original, after checking for nasties. -- MJR| Make it easy for your readers to find their way around your web ---' site with good navigation links. The two most common places are the side-bar menu and the top-of-screen menu. Where is yours? |-----[ Luminas internet applications http://www.luminas.co.uk/ ]-----|
Can anyone give me a hint as to why "sed s/word1/word2/g filename" displays the file 'filename' with word2 in place of word1 but the change isn't made permanent? Thanks, Jen
because sed is a filter that reads from stdin and write to stdout. So your command should be something like; sed s/word1/word2/g filename > newfilename (Hey! I actually knew the answer to something!!) Keith :o) ____________ Whatever thou sayest of God is untrue. Meister Eckhart
On 19-Aug-02 Jenny_Hopkins@toby-churchill.com wrote:
Hi all, Can anyone give me a hint as to why "sed s/word1/word2/g filename" displays the file 'filename' with word2 in place of word1 but the change isn't made permanent? Thanks, Jen
Sed write to stdout. You have to redirect its output somewhere. You cannot do an update in-place with it. ---------------------------------- E-Mail: Raphael Mankin <raph@panache.demon.co.uk> Date: 22-Aug-02 Time: 13:32:40 ----------------------------------
participants (4)
-
Jenny_Hopkins@toby-churchill.com -
Keith Watson -
MJ Ray -
Raphael Mankin