I want to replace a string by a environment variable containing a SMTP url (so with @,: and /) in a file. How can I achieve that in a bash command?
I tried with sed but I think the @ is broking my command.
sed -i -- s/{{MAIL_URL}}/"$MAIL_URL"/g *
Thanks for your help!
Your SMTP url may contain /
characters which coincide/break sed
expression delimiter /
.
Change sed
expresssion delimiter to another character:
sed -i "s~{{MAIL_URL}}~$MAIL_URL~g" *
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.