我想替换输入文件中的文本。输入文件包含以下输入文本:
...
[
%% Riak Client APIs config
{riak_api, [
%% pb_backlog is the maximum length to which the queue of pending
%% connections may grow. If set, it must be an integer >= 0.
%% By default the value is 5. If you anticipate a huge number of
%% connections being initialised *simultaneously*, set this number
%% higher.
%% {pb_backlog, 64},
%% pb is a list of IP addresses and TCP ports that the Riak
%% Protocol Buffers interface will bind.
{pb, [ {"192.168.75.999", 8087 } ]}
]},
%% Riak Core config
...
我尝试输入以下 SED 正则表达式:
sed -i -e "s/\d{1,3}.\d{1,3}.\d{1,3}.\d{1,3}\", 8087/$my_ip\", 8087" /path/to/file
因此,我希望将旧 IP 地址 192.168.58.999 替换为服务器的实际 IP 地址。“my_ip”变量与前一步的服务器 IP 值一起归档。SED 执行正则表达式并返回而没有错误,但也没有对文件进行任何更改。
我将不胜感激有关此问题的任何帮助。(我使用的是 Ubuntu 12.04.2,64 位)