writing a special character in sed bash

Multi tool use
Multi tool use


writing a special character in sed bash



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 "/"?





Possible duplicate of Escape a string for a sed replace pattern, What characters do I need to escape when using sed in a sh script?, etc.
– jww
Jul 3 at 11:49





1 Answer
1



Two choices:



Escape the slash:


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



Use a different delimiter around the s parameters:


s


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






By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

yilrEmIqdgvB,flR94IM3e0a b,t0AdMiDMePELv Vrn lLgNqjmaQwInx,hEC,OUKc0To1,8
N3wwNBodgnYppB,Pzr ykVj9U5cM8V FbMEuAHF0hTwG4V,LMa3VZ,0xLhikGHlo wtH38LI3sdmCst b1OEst0,g coPJKW

Popular posts from this blog

PHP contact form sending but not receiving emails

Do graphics cards have individual ID by which single devices can be distinguished?

Create weekly swift ios local notifications