Linux String Substitute

Hi KodeKloud team,

Could you please let me know why this task is showing failed:

image

Hello Team,

Can you please update on this… was it wrong what is the process to request for review this question.

Thank you.

@subhash.max, do you have task statement ?

My task was to replace About with Torpedo but I don’t have the print screen of it.
Can’t it be checked from from logs, I was not aware to keep the task statement during that time.

@subhash.max, do you remember the case about or About as sed is going to look for exact case for pattern you are replacing.

Yes I do remember.
About (Caps A) need to be replace with Torpedo (Caps T).

There was not a single About (caps A), all strings was about (small letters).
You can see in first image, replacing About (caps A), not changed anything. when About (caps A) was replaced then only result case as 0 (zero).

I could be wrong but i suspect, you already change About with Torpedo in your first command, then you ran an egrep with -i (non-case sensitive) which will consider even about (lower case) and give the count.
File might be having about as well which your third command replaced. Not part of task.
May be that caused the task to fail.

By any change did you ran grep About nautlis.xml | wc -l before of after running your first sed command

There were no “about” string in the file, it was checked before sed but not captured in print screen.
Also if it was replaced in my sed command then why “egrep Torpedo nautlis.xml | wc -l” was 0.

egrep -i About nautlis.xml | wc -l

66

egrep Torpedo nautlis.xml | wc -l

0

I had the same issue and the task was also failed.

Solution with details: Linux String Substitute Kodekloud

1 Like

hey guys,
follow this

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

hey guys,

follow this

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