将自己的 IP 输入 SED 命令的正确语法是什么
Whats The Correct Syntax to input the Own IP into an SED Command
sed -i 's/# ListenIP=0.0.0.0/ListenIP=$[hostname -I]' /etc/some.conf
我需要将 Listen Ip 更改为自己的 IP,那么在 SED 命令中插入 hostname -I
的正确方法是什么?
使用命令替换$()
调用子shell:
sed -i "s/# ListenIP=0.0.0.0/ListenIP=$(hostname -I)/" /etc/some.conf
sed -i 's/# ListenIP=0.0.0.0/ListenIP=$[hostname -I]' /etc/some.conf
我需要将 Listen Ip 更改为自己的 IP,那么在 SED 命令中插入 hostname -I
的正确方法是什么?
使用命令替换$()
调用子shell:
sed -i "s/# ListenIP=0.0.0.0/ListenIP=$(hostname -I)/" /etc/some.conf