I have shell script and as part of the script I want to update the a.conf file (it is configuration file) which includes key-value pair, I want to update the values of the key. Script ask user to input the values which I am storing into variables. How could I update the multiple values in below file by using those variables. I tried sed but not sure how to use it for only to modify value of a particular key
a.conf file
key1=value1
key2=value2
I tried below sed command but it is not updating the value of given key -
sed -i -e "s/\($key1 *= *\).*/\1$newvalue/" $CONFIG_FILE
Update
If I update above command by removing space between *=*\ then, newvalue get appended to existing value e.g. key1=value1newvalue
Not sure what I am missing here
.conf), this is not ajsonfile.Tafter$key1supposed to be there?