I'm trying to replace only part of the existing variable with a new user input variable as below:
#Current Variable:
gdbName=Test.MY.DOMAIN.COM <--I need to replace the "Test" (This can be any other string not just Test e.g. CDB79 etc.) part only in this variable with new user input variable.
#New user input variable:
read -p "Enter CDB Name : " CDBName
#I tried the following line:
sed -i "s/gdbName=*.MY.DOMAIN.COM/gdbName=$CDBName/" somefile.txt
but it replaces the whole variable.
Any suggestions?
Note: I am updating the variable in a file.
gdbName=*.MY.DOMAIN.COM
? That means matchgdbName
, then 0 or more=
and then any character, followed byMY.DOMAIN.COM
. Maybe you wanted.*
instead? What is thisdbca.rsp
file? Is that where the replacement should occur? So it isn't actually a variable but a file?gdbName
that exists in your environment, or trying to change the contents of a file that contains the linegdbName=Test.MY.DOMAIN.COM
? Please edit your question to clarify. and provide concise, testable sample input and expected output.$CDBName
ever contain a&
or\1
or/
or newline?