I want to replace a string with sed and save changes to same file which needs sudo as its a root owned file.
But while doing that I am getting below error
raja@raja-UbuntuVM:~$ sudo sed 's|gateway 192.168.56.1| |g' /etc/network/interfaces
# interfaces(5) file used by ifup(8) and ifdown(8)
auto lo
iface lo inet loopback
iface eth1 inet static
address 192.168.56.102
netmask 255.255.255.0
-bash: syntax error near unexpected token `newline'
raja@raja-UbuntuVM:~$ sudo sed 's|gateway 192.168.56.1| |g' /etc/network/interfaces > /etc/network/interfaces
-bash: /etc/network/interfaces: Permission denied