Jens Puruckherr wrote:
Hallo,
wie mache ich aus einer dhcp.conf eine csv-Datei, in der alle
host xxxx { hardware ethernet 00:00:00:00:00:00; fixed-address 192.168.200.71; }
Natuerlich mit awk.
cat dhcp.cnf | gawk -f adressen.awk
*oder*
gawk -f adressen.awk dhcp.cnf
(damit ich nicht fuer den "Useless Use Of cat Award" vorgeschlagen werde :-))
stefan2@platon:~/awk_material> gawk -f adressen.awk dhcp.conf xxxx1,00:00:00:00:00:00,192.168.200.71 xxxx2,00:00:00:00:00:00,192.168.200.72 xxxx3,00:00:00:00:00:00,192.168.200.73 xxxx4,00:00:00:00:00:00,192.168.200.74
Listing adressen.awk
------------------------ cut here ---------------------
/host/ { start = 1; ende = 0; hostname = $2; }
/hardware/ { eth = $3; }
/fixed/ { fixed = $2; gsub(/;/,"",eth); gsub(/;/,"",fixed); printf("%s,%s,%s\n",hostname,eth,fixed); }