Sys-Admin

Introduction

Sed is used to search and modify string.

Substitute string Get number of word About in the dista.xml documents.

cat /root/dista.xml | grep About | wc -l

Replace the word About with ResCF.

sed -i -e 's/About/ResCF/g' /root/dista.xml

's/About/ResCF/g'

Options

There is some data on Nautilus App Server 3 in Stratos DC. Data needs to be altered in some of the files. On Nautilus App Server 3, alter the /home/BSD.txt file as per details given below.

a. Delete all lines containing the word following and save the results in /home/BSD_DELETE.txt file. (Please be aware of case sensitivity)

b. Replace all occurrences of the word and (look for the exact match) with their and save the results in /home/BSD_REPLACE.txt file.

Note: Let’s say you are asked to replace the word to with from. In that case, make sure not to alter any words containing the string itself, for example; upto, contributor etc.

sed -n '/following/!p' /home/BSD.txt > /home/BSD_DELETE.txt
sed 's/\band\b/their/g' /home/BSD.txt > /home/BSD_REPLACE.txt