How to replace placeholder character or word in variable with value from another variable in Bash?

后端 未结 8 2075
死守一世寂寞
死守一世寂寞 2020-12-08 14:01

I\'m trying to write a simple Bash script. I have a simple \"template\" variable:

template = \"my*appserver\"

I then have a function (

8条回答
  •  萌比男神i
    2020-12-08 14:03

    String replacement in a bash-script can e.g. be achieved by sed:

    template=$(echo $template | sed 's/old_string/new_string/g')
    

    This will replace old_string with new_string in the template variable.

提交回复
热议问题