I am trying to change the whole line in a file matched by part of the line only.
e.g. the command below works fine as "$Netconf_DHCPStart" doesn't have a /
in it:
sed -e '/DHCP_START=/c\DHCP_START='"$Netconf_DHCPStart"
However, the command below doesn't work
sed '/static ip_address='"${Current_StaticIP}"'/c\static ip_address='"$Netconf_range"'.110' /etc/dhcpcd.conf
giving error:
sed: -e expression #1, char 32: unknown command: '2'
I know that this is because "$Current_StaticIP" contains a /
within it, however, I am not sure how to format it so it will work. Do I need to escape the \
within the variable first?
$Current_StaticIP
variable contains a forward-slash, prematurely ending the/static ip_address.../
search – Jeff Schaller Sep 19 '18 at 14:27