简体   繁体   中英

Using linux shell script using sed replacing "\"

I need to replace char "\\" and it is not working. my script as follow. I'm using same script for many other replacements and somehow this is not working.

export VCA='http:\\/\\/localhost\\/dev1'
export VCB='https:\\/\\/www.mydomain.com'
sed "s~${VCA}~${VCB}~g" tmp2.sql > tmp3.sql

I don't see error anymore but it does not replace the string.

Try:

VCA='http://localhost/dev1' 
VCB='https://www.example.com'
sed "s~${VCA}~${VCB}~g" tmp2.sql > tmp3.sql

Note: stackoverflow 's answer text editor seems to dislike having www.mydomain.com in the code, so $VCB uses a dummy value which can be changed back as needed.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM