0

I have following content in a file

return o.baseUrl="http://info.example.com/api/v1/",a.init=t,o.login=e(o.baseUrl+"login",{email:"@email",password:"@password"}

I want to replace info.example.com with api.example.com

Currently I am using

sed -i "s/^info\.example\.com.*$/api.example.com/g" /var/html/www/index.js

But this is not working. I don't know much about regular expression. Can somebody help me on this ?

1
  • 1
    Drop ^ and .*$ Commented Jul 5, 2017 at 5:55

2 Answers 2

1

^ anchor matches info\.example\.com at the beginning of the lines.

Anchors are useless in your case. Remove the ^ and $ from your pattern:

sed -i 's/info\.example\.com/api.example.com/g' /var/html/www/index.js

More about anchors here.

Sign up to request clarification or add additional context in comments.

Comments

1

In sed you can provide exact expression to be replaced.

sed 's/info\.example.com/api.example.com/g' file

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.