SED replace string

Hi Team,

I used below command to replace the string Text to Cloud.

sudo sed ‘s/Text/Cloud/g’ /root/nautilus.xml

As oer result this was replaced successfully. I only replace Text with capital T, as given in the question. But in the xml there were some string with small t also, that was not replaced and system failed my task.

Error:

  • all occurences of ‘Text’ have not changed to ‘Cloud’ in the file ‘/root/nautilus.xml’ on stbkp01

why task was failed when in the question only string “Text” needed to replace with its capital T.

You need to add -i to the command like:

sed -i ‘s/Text/Cloud/g’ /root/nautilus.xml
without -i it just acts like a dry run , it doesn’t change the file contents just shows you what will be the final output if you fire this command

1 Like

Thank you,

I understand this filter, but I was confused for the task statement as there only text with capital T was given,

anyway, I failed that task, let’s see the next.

1 Like