ACC SHELL
#!/bin/sh
#
# wol-dhcpdconf - parse a dhcpd.conf and output it in macfile format
#
# $Id: wol-dhcpdconf.in,v 1.5 2003/08/09 12:34:55 wol Exp $
#
# Copyright (C) 2002 Thomas Krennwallner <krennwallner@aon.at>
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#
gawk '
BEGIN {
mac = "" # all MAC Addresses are stored in this string
ip = "" # all IP Addresses are stored in this string
}
/^[ \t]*hardware[ \t\n]+ethernet[ \t\n]+[0-9a-zA-Z:]+;/ {
sub (/;/, "", $3) # rm semicolon
mac = mac " " $3
}
/^[ \t]*fixed-address[ \t\n]+[0-9a-zA-Z._-]+[ \t\n]*;/ {
sub (/;/, "", $2) # rm semicolon
ip = ip " " $2
}
END {
len = split (mac, MAC, " ")
split (ip, IP, " ")
for (i = 1; i <= len; ++i)
print MAC[i], IP[i]
}'
ACC SHELL 2018