Linux String Substitute (sed) taskB failed

Hello,
I am new to the platform KodeKloud. I encounter a problem on task B which is not complete but I do not understand my error.

task a : sed ‘/software/d’ /home/BSD.txt | sudo tee /home/BSD_DELETE.txt

Task B : sed ‘s/ and / is /g’ /home/BSD.txt | sudo tee /home/BSD_REPLACE.txt
grep ‘and’ /home/BSD_REPLACE.txt
grep ‘is’ /home/BSD_REPLACE.txt

When I check my lab I have this message:

  • Make sure to replace all the occurences of ‘and’ to ‘is’ in ‘/home/BSD_REPLACE.txt’ on stapp01

Hi @thanh24

It asks for you to substitute word and for is.

Surrounding and with a space either side isn’t how you find a word. What about punctuation?
and, is still an ocurrence of the word, also "and" but your expression won’t find that!

Sed has a word boundary operator that will match anything that is a valid boundary, eg punctuation or white space. It is \b

So the search expression is /\band\b/

Google for sed word boundary for a fuller explanation and some examples

@Alistair_KodeKloud
Thank you for your return. I did not know sed word boundary.
We learn every day.

Have a wonderfull day.