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:
iface lo inet loopback
iface eth0 inet static
iface eth1 inet dhcp
iface eth2 inet dhcp
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.