I have a file where I have a bunch of server IPs ( either null or with some IP)
Scenario 1(File contents):
export Server1=""
export Server2=""
Scenario 2:
export Server1="10.10.10.1"
export Server2="10.10.10.2"
In both of the above cases I want to substitute the values for Server1 and Server2. I tried the following
Server1="11.11.11.1"
Server2="11.11.11.2"
sed -i -e 's/export Server1=""/export Server1=\$Server1/g' file.txt
sed -i -e 's/export Server2=""/export Server2=\$Server2/g' file.txt
For the first scenario the file gets replaced with the string instead of the value for vars
File content after substitution
export Server1=$Server1
export Server2=$Server2
I tried escaping the "$" character but it didnt work. What am I missing?