我想将一个特定的IP替换为另一个,所以将localhost改为0.0.0.0
sed -i -e 's/localhost/0.0.0.0/g'
似乎无法正常工作
也试过sed -i -e 's/localhost/0\.0\.0\.0/g'
无法正常工作
sed:RE错误:非法字节序列
答案 0 :(得分:0)
您的示例似乎对我很好。鉴于以下test.txt
ip=localhost
以下内容将ip=localhost
替换为0.0.0.0
sed -i -e 's/ip=localhost/0\.0\.0\.0/g' test.txt
如果您只想更换localhost
部分:
sed -i -e 's/localhost/0\.0\.0\.0/g' test.txt
将为您提供以下内容:
ip=0.0.0.0