I need to replace all the occurrences of a placeholder in a file. I'm using bash script for it.
I have tried the below command:
$Service_Name="ABC"
sed -i "s/_servicename_/$Service_Name/" XYZ.java
It only replaces the first word of a placeholder in a line in a file not multiple placeholders in a line.
Example:
If the line in the file is :
_servicename_WorkerException(String.format(_servicename_Test.Failed.getMessage()));
Now the output looks like this:
ABCWorkerException(String.format(_servicename_Test.Failed.getMessage()));
I want the below output:
ABCWorkerException(String.format(ABCTest.Failed.getMessage()));
Can someone help with the missing part?
Appreciate all your help! Thanks in advance!