I have a config. file for apache zookeeper which looks like this:
tickTime=2000
initLimit=10
syncLimit=5
dataDir=/zookeeper/zkdata
clientPort=2184
server.1=10.1.1.191:2888:3888
server.2=10.1.1.70:2889:3889
server.3=10.1.1.71:2890:3890
I created a bash script that deletes the cfg file and replaces it with the exact same information except a different server.1=IP. This IP is variable and I need to change it very rarely. I want to know if there is a way to find the 10.1.1.191 and replace it with lets say 10.1.1.192 without doing:
rm zoo.cfg
echo "tickTime=2000" >> zoo.cfg
echo "initLimit=10" >> zoo.cfg
... (and so on till...)
echo "server.1=$1:2888:3888" >> zoo.cfg
echo "server.2=10.1.1.70:2889:3889" >> zoo.cfg
echo "server.2=10.1.1.71:2890:3890" >> zoo.cfg
This is my method right now. Delete zoo.cfg and replace with new ip for server.1.
Is there a way to find and replace the IP for server.1 in a bash script instead of deleting file?