0

I have a config file that need to replace DBpass and host ip when deploy

some code look like this: {DBPASS}@{ip}

I create a scripts file to replace them like this

echo "Host IP?"
read ip
sed -i 's/{ip}/$ip/g' abc.conf
echo "DB pass?"
read dbpass
sed -i 's/{DBPASS}/$dbpass/g' abc.conf

and it turn out to be like this in config file $dbpass@$ip

So how can I make the sed command in shellscripts replace the word I input before.

1 Answer 1

2

change the single quotes ' into double quotes " in your sed commands, so that the shell variables can be expanded.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.