Issue
└─$ sed --version
sed (GNU sed) 4.7
file "hosts":
ip1 == 10.0.0.1
ip2 == 10.0.0.100
command executed:
sudo -i sed -i 's/10.0.0.1/10.0.0.200/g' hosts
Output file :
ip1 == 10.0.0.200
ip2 == 10.0.0.20000
The change in ip2 is not expected and an invalid. This is just a sample logic need this logic for a Cloud Automation in RPA. The Inputs of ip are dynamic vars.
Solution
This both helped me resolve it. i.e.
$
sudo -i sed -i 's/10.0.0.1\b/10.0.0.200/g' hosts
or
$
sudo -i sed -i 's/<\10.0.0.1\>/10.0.0.200/g' hosts
More Responses are welcome.
Answered By - Alice Golakiya Answer Checked By - Dawn Plyler (WPSolving Volunteer)