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 ?
在sed
您可以提供要替换的确切表达式。
sed 's/info\.example.com/api.example.com/g' file
^
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 .
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.