Home > Software design >  Whats The Correct Syntax to input the Own IP into an SED Command
Whats The Correct Syntax to input the Own IP into an SED Command

Time:05-04

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?

CodePudding user response:

Use command substitution $() to call a subshell:

sed -i "s/# ListenIP=0.0.0.0/ListenIP=$(hostname -I)/" /etc/some.conf
  •  Tags:  
  • bash
  • Related