Hi,
I am new to shell scripting.
I use Solaris10 machine.I have to write a simple shell script which replaces a part of string a file.
my file name is properties.ini, which has the following values
#application properties
location.mysql = /opt/bin # ( here location.mysql is considered as #key and /opt/bin is considered as value )
location.java = /usr/bin
Now
when i run a shell script I have to replace the value of location.mysql from /opt/bin to /opt/xyz
Currently I user the following code Which i am able to replace.
#!/bin/sh
KEY=location.mysql
VALUE=/opt/xyz
FILE=./properties.ini
sed "s|^$KEY.*|$KEY=$VALUE|g" $FILE > ./temp.bak
mv ./temp.bak $FILE
The above code is working fine, but in the code after replacing the value from location.mysql=/opt/bin to location.mysql=/opt/xyz I am moving into a file called temp.bak(temporarily) , and then moving back that file into its original name(properties.ini)
Is there any solution to replace the value in the file permanently with out moving the files.
Thanks in advance,
RaghuDeep Amilineni