Quantcast
Channel: Active questions tagged config - Stack Overflow
Viewing all articles
Browse latest Browse all 5049

Use read -p command to save response and overwrite a config file in script [duplicate]

$
0
0

This question already has an answer here:

So I have a configuration file that I want to change after receiving a prompted response from the user.

read -p 'Your RPC Username: ' RPC_USER
sleep 1s
echo -e "${YELLOW}"
echo "$RPC_USER"
echo "----------------"
echo "Is this correct?"
echo -e "${RED}"
select yn in "Yes""No"; do
    case $yn in
        Yes ) break;;
        No ) read -p 'New RPC Username: ' RPC_USER
            echo "$RPC_USER"
    esac
done

After this I want to change a file configuration say: test.conf. So I try:

sed -i '1i RPC_USERNAME="$RPC_USER"' ~/test.conf

But only thing I get is:

RPC_USERNAME="$RPC_USER"

Again this is to be able to paste these user input variables directly into the configuration file for them during the script.

Any help is greatly appreciated!


Viewing all articles
Browse latest Browse all 5049

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>