Linux String Substitute Task

I was assigned the task to replace all the ‘Text’ occurrences by ‘LUSV’ in the /root/nautilus.xml file.
I think I did complete my task without any error, but still it got marked as failed.
I used the sed utility as: “sed -i ‘s/Text/LUSV/g’ nautilus.xml”
Can anyone please help me with the reason behind this task, considered as failed?

hey @heet59

i assume that the task wasn’t clear enough.
or maybe that a (Linux) system admin must be aware of the importance of the uppercase and lowercase detail of such task!

sed command will take “Text” just “text”
in order to replace “Text” with capital T and the rest is lowercase
you have to alter your command.

I think in your sed command should look like this :
sed -i ‘s/\<Text\>/LUSV/g’ nautilus.xml

note the \< and \> added to the command for the word “Text” since it’s the one to be replaced
it tell to find exactly that word with uppercase and lowercase indicated.

hope it helps!

Hi @heet59

We just reviewed your answer and found that in your original answer you didn’t use the option -i so your changes were not saved, hence the answer was marked as failed. Also please note that any changes made after clicking on Finish button are not considered.

@siraj_krm thanks for explanation but sed does care about case sensitivity by default so it will not consider Text as text by default. Please check here for more details:

If by chance you are testing on macOS - as of Mojave (10.14) then it might be a different case for you, please check this:

1 Like

Thank you for the detailed explanation. I might have forgot to use ‘-i’ option with sed.

Thank you for bringing this to my notice also. :slight_smile: