I have a file named MyFile.txt with the following contents:
Username=myusername
EncryptedPassword=9k3S+sS3g\=\=
Each time I need to change the username and password I run a shell script. In the shell script I store the save username and password to two variables namely:
oldusername="myusername"
oldpassword="9k3S+sS3g\=\="newusername="mynewusername"
newpassword="U8djlk+h\=="
sed -i "s/$oldusername/$newusername/g" MyFile.txt
sed -i "s/$oldpassword/$newpassword/g" MyFile.txt
The first sed works properly and replaces the username, however the second sed command doesn't work and the password is not changed in the file. I think it is because of the "\" character present in the variables.
Could someone help me out with this and let me know how to go about it?
Thanks..