Hi there,
Can anyone help me find the correct expression for sed.
I want to repace iface eth0 inet wathever
with iface eth0 inet static
Thanks for your help
Santiago
Hi there,
Can anyone help me find the correct expression for sed.
I want to repace iface eth0 inet wathever
with iface eth0 inet static
Thanks for your help
Santiago
Try:
sed 's/\(iface eth0 inet\).*/\1 static/'
Regards
sed '/^iface eth0 inet / s/^\(iface eth0 inet\).*/\1 static/' /etc/network/interfaces
A back reference is always only valid within the substitution and can't be kept across commands.
sed '/iface eth0 inet/s/\(.*\) .*$/\1 static/' file
$ echo 'iface eth0 inet wathever foo' | sed '/^iface eth0 inet / s/^\(iface eth0 inet\).*/\1 static/'
iface eth0 inet static
$ echo 'iface eth0 inet wathever foo' | sed '/^iface eth0 inet / s/^\(iface eth0 inet\) *\([^ ][^ ]*\) *\(.*\)/\1 static \3/'
iface eth0 inet static foo
Thanks Franklin52, pludi, danmero and vgersh99.
pludi is right when he says: