Reputation: 58652
I would like to replace a line of this file /Users/jdoe/Sites/vue/app/public/index.html
from
window.API_URL = "anything"
to
window.API_URL = "http://api.local:1234
sed -i -e 's/.*window.API_URL.*/window.API_URL = "http://api.local:1234"/g' /Users/jdoe/Sites/vue/app/public/index.html
Kept getting
sed: 1: "s/.window.API_URL./wi ...": bad flag in substitute command: '/'
Upvotes: 0
Views: 43
Reputation: 66
you need the \
to escape the /
in the url, this should work:
sed -i -e 's/.*window.API_URL.*/window.API_URL = "http:\/\/api.local:1234"/g' index.html
also if you prefer awk:
awk -i inplace '/window.API_URL/ {$3=" \"http://api.local:1234\""} 1' index.html
Upvotes: 1