Linux String Substitute (sed)

sudo sed ‘/ copyright /d’` /home/BSD.txt > /home/BSD_DELETE.txt

not sure, if the space before and after copyright caused the task to get failed.

@Inderpreet @vijin.palazhi @rahulsoni @peterwhite
Please check and comment.
@peterwhite Thanks for your valuable inputs, I got to know, I was supposed to log in as a root user. Then try to update the file, that’s correct?

I should have validated my results against the requirements of the question.
Which I din’t do in this question, feeling bad for me. thanks
Swaroop

Hi @Inderpreet, I think I did everything correctly and still it got failed. Request you to review my task once and let me know the details.

You’re quite welcome, Swaroop, that is correct.

Hi @peterwhite

Sorry for inconvenience, your answer is marked as SUCCESS and issue is fixed now.

Please note that you were supposed to delete the entire line containing the word copyright but you only deleted the word itself, hence your answer was marked as failed.

Please notice the spaces before and after copyright (sed ‘/ copyright /d’) in your command that made it not to match the pattern hence changes were not made correctly.

1 Like

Hi @Inderpreet. No worries, I’m happy to help improve the platform. Thanks for taking care of this.

2 Likes

Thank you Inderpreet. I should have been little more wary.
Have a great day ahead!
Swaroop

Completed the Task with below

ssh clint@stbkp01
sudo su -
ls -al( to check if Nautilus.xml file is present in root)
cat /root/nautilus.xml (to view how many instances of old String value are there)
sed -i ‘s/String/Submarine/g’ /root/nautilus.xml
cat /root/nautilus.xml (all instances are changed to new string )

task is completed.

For troubleshooting/solution video refer below. These videos are made just to help the community!

2 Likes

Thanks Peter. Those are valuable inputs learned something today. I was unable to switch to root figured it out after multiple failures.

Hi I have the same problem do that like video and check them by cat command but in conform faild!!!

its fake video don’t follow it try your own. google it you will find the solution.

I believe I did the right things but the task failed saying the statement below:

Make sure to replace all the occurrences of ‘or’ to ‘them’ in ‘/home/BSD_REPLACE.txt’ on stapp01

Hey
I facing the same issue myself
please assist

Hey guys,
follow this

sudo sed -i ‘s/String/Software/g’ /home/BSD.txt
(old text/new text)

Hi,
so this is where we’re going wrong:
in the task one it says delete “all lines” containing the word software, but we’re trying to delete just the word, so try this:
sed ‘/software/d’ BSD.txt > BSD_DELETE.txt
replace the word software with the word asked in the task

I have similar issue , can someone review and advise.
[root@stapp03 home]# sed -i ‘/copyright/d’ /home/BSD.txt > /home/BSD_DELETE.txt
[root@stapp03 home]# sed -i ‘s/and/their/g’ /home/BSD.txt > /home/BSD_REPLACE.txt
[root@stapp03 home]#


Thank you already.

Just replace -i with -e.
The rest is fine.