Linux System Adminastrator: Linux String Substitute KodeKloud



KodeKloud Task

Question: Your Backup Server has a file named nautilus.xml in root folder. Replace all occurrence of "Sample" word by "Architecture" in nautilus.xml file

Solution: Use sed command to replace all occurrence of a word by another word

sudo sed -i 's/Sample/Architecture/g' nautilus.xml

Here s/ means substitute and g/ means global replace of all occurrence

Search previous word Sample by grep command to check

cat nautilus.xml | grep "Sample"

There should be no output

Search current word Architecture 

cat nautilus.xml | grep "Architecture"

Output should be highlighted searched word

Check Server Screenshot:




Download Coding Interview Book and Get More Tutorials for Coding and Interview Solution: Click Here

Download System Design Interview Book and Get More Tutorials and Interview Solution: Click Here

Do you need more Guidance or Help? Then Book 1:1 Quick Call with Me: Click Here

Share on Google Plus

About Ashadullah Shawon

I am Ashadullah Shawon. I am a Software Engineer. I studied Computer Science and Engineering (CSE) at RUET. I Like To Share Knowledge. Learn More: Click Here
    Blogger Comment
    Facebook Comment

0 comments:

Post a Comment