I just completed a task which was to replace all occurence of About with Cloud on an xml file on the backup server
I used this command
sudo sed ‘s/About/Cloud/g’ /root/nautilus.xml
and I confirmed the changes in the output but still failed the task
Hello,
Thank you for reporting this. The command you used seems fine to see what changes sed
command is going to make however its not actually editing the target file i.e nautilus.xml
. You should have used the same command with option like -i
so that you could actually insert/save the changes into the target file.
Thanks
Inderpreet
Thanks for the response. So this command would have worked
sudo sed -i ‘s/About/Cloud/g’ /root/nautilus.xml
Hello, I have some issues with this. Actually, I use command cat /root/nautilus.xml | sed -e ‘s/Random/LUSV/’ then use -i .
And I get the failed task. If I use -e that will be the right answer or still wrong?
Hi,
The -e
option is used to add the script to the commands to be executed. In general your command should work fine and should display the correct output but again it will not save the changes to the target file hence you should have used -i
option.
Thanks
Inderpreet