Given the following example file:
host wallmount {
option root-path "iscsi:10.0.0.202::::iqn.2012-01.com.enactpc:storage.wall_mount";
hardware ethernet 00:15:c5:71:b9:68;
}
host netbook {
option root-path "iscsi:10.0.0.202::::iqn.2012-01.com.enactpc:storage.netbook";
hardware ethernet 00:21:70:bb:4e:95;
}
host laptop {
option root-path "iscsi:10.0.0.202::::iqn.2012-01.com.enactpc:storage.laptop";
hardware ethernet 00:1b:38:4c:62:40;
}
Would it be possible to take a known “hostname” (eg. “wallmount”) and remove it’s entire declaration automatically?
P.S. This is a DHCP config file under Linux… I don’t know if that helps or not.
I’d do it with sed, which can be as simple as:
This is not going to be completely robust (because it does not fully understand all the syntax that the real parser of your config probably does), but if your inputs are pretty regular as your example is, it should work fine.
In case you don’t know sed, here’s how you’d edit a file in place using the above command: