0
sed -i 's/# ListenIP=0.0.0.0/ListenIP=$[hostname -I]' /etc/some.conf

I need to Change the Listen Ip to its own IP, so what's the correct way of inserting hostname -I into the SED command?

0stone0
  • 21,605
  • 3
  • 29
  • 49

1 Answers1

0

Use command substitution $() to call a subshell:

sed -i "s/# ListenIP=0.0.0.0/ListenIP=$(hostname -I)/" /etc/some.conf
0stone0
  • 21,605
  • 3
  • 29
  • 49