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