0

I have a problem, because I want to replace

QueryConnection::DefaultChannel=

with

QueryConnection::DefaultChannel=/${CHANNEL NUMBER}

e.g: QueryConnection::DefaultChannel=/5

My code:

sed -i "s/QueryConnection::DefaultChannel=.*/QueryConnection::DefaultChannel=${NUMER_KANALU}/" "${DIR_BOTS}/bot_${COUNT_BOTS}/configTS3AudioBot.cfg"

How to make before ${NUMER_KANALU} be "/"?

Mezir
  • 31
  • 4
  • Possible duplicate of [Escape a string for a sed replace pattern](https://stackoverflow.com/q/407523/608639), [What characters do I need to escape when using sed in a sh script?](https://unix.stackexchange.com/q/32907/56041), etc. – jww Jul 03 '18 at 11:49

1 Answers1

0

Two choices:

  1. Escape the slash:

    sed -i "s/QueryConnection::DefaultChannel=.*/QueryConnection::DefaultChannel=\/${NUMER_KANALU}/" "${DIR_BOTS}/bot_${COUNT_BOTS}/configTS3AudioBot.cfg"
    
  2. Use a different delimiter around the s parameters:

    sed -i "s#QueryConnection::DefaultChannel=.*#QueryConnection::DefaultChannel=/${NUMER_KANALU}#" "${DIR_BOTS}/bot_${COUNT_BOTS}/configTS3AudioBot.cfg"
    
Barmar
  • 741,623
  • 53
  • 500
  • 612