hello
I have this:
sed -e "s/install_location=....../g" -e "s/hostname=....../g" -e "s/server_name=....../y" input.txt
it will display on the screen what have changed. however I want to change file input.txt. Any idea other than doing redirection (>)
thx
i9300
2
before i use sed to edit a file, first i backup the file, then i sed it with the backup into the orig file.
cp input.txt input.txt.bak
sed -e "s/install_location=....../g" -e "s/hostname=....../g" -e "s/server_name=....../y" input.txt.bak>input.txt
Sorry, I do not know of a way without redirection
danmero
3
If your sed support -i switch(backup file).
sed -i .bak -e "s/install_location=....../g" -e "s/hostname=....../g" -e "s/server_name=....../y" input.txt && rm input.txt.bak || mv -f input.txt.bak input.txt
If sed fail, restore the file from backup, if not remove the backup file.