I have a file that contains a multiple single lines that specify an item, and then a list under each item. I want to basically edit the file so that I can delete a list and replace it with my own list.
For example, /etc/network/interfaces:
Code:
auto lo
iface lo inet loopback
auto eth0
iface eth0 inet static
address 192.168.0.1
netmask 255.255.255.0
gateway 192.168.1.1
auto eth1
iface eth1 inet dhcp
iface eth2 inet dhcp
auto eth2
How would I go about setting new parameters for all the fields under eth0? My thought was to delete everything from 'auto eth0' or 'iface eth0' to, but not including, 'auto eth?' or 'iface *' or 'EOF', and then append my own configuration onto the bottom. Is there a simple way to do this, or any suggestions about how to go about it?
Yes, I know that for this example, I could just 'sudo vim /etc/network/interfaces' and edit the file, but I would like to attempt to automate the process in C eventually.