bash replace variable name in string with variable value

前端 未结 2 1405
孤独总比滥情好
孤独总比滥情好 2021-01-29 02:13

This is kind of a weird one. I have the following string:

I have a variable called REDIRECT set to: https://working.${MYDOMAIN}/blah/blah.

I need to

2条回答
  •  清歌不尽
    2021-01-29 02:50

    You may use this bash substitution:

    echo "${REDIRECT/\${MYDOMAIN\}/$MYDOMAIN}"
    

    or else, if you have envsubst utility then use:

    export MYDOMAIN
    envsubst <<< "$REDIRECT"
    

提交回复
热议问题