Hi all,
I'm trying to take a dhcpd.conf file and replace each IP address in
it with a host name. The address-to-hostname map is in hosts. This is
what I've got so far:
sed -e '/\([0-9]\{1,3\}[.]\)\{3\}[0-9]\{1,3\}/R hosts' dhcpd.conf
So far, this appends a single line from hosts to the matched line in
dhcpd.conf, here is sample output:
fixed-address 192.168.1.81;
192.168.1.92 term012
The first line is from dhcpd.conf and the second is from hosts.
However, I have not been able to figure out how to append the
appropriate line; at the moment, it's going in sequence through hosts
and the lines being appended do not match the IP.
I've tried to get the output of grep piped into the read file, a la:
sed -e '/\([0-9]\{1,3\}[.]\)\{3\}[0-9]\{1,3\}/R `grep \1 hosts`'
dhcpd.conf
But it does nothing. I've tried several variants to no avail.
1) So the first task is to get the proper lines appended to the proper
places.
2) The second task is to modify the new data to have only the host
name.
To the best of my knowledge, reading does not affect the pattern space.
Is it possible to accomplish this in one pass if the pattern space is
not affected? Will I have to write the output to a new file and then
sed it again to get the results I want?
Any and all help is appreciated.
TIA,
Al