#!/bin/awk -f # # Simple awk script to obtain list of ip address v. mac address from # /etc/ethers. It ignores all lines starting with '#' and only outputs # anything for hosts with a corresponding entry in /etc/hosts. The # output is suitable for the RARPD.TBL needed by Lew Perin's RARPD. To # use: # # rarpd.awk /etc/ethers > RARPD.TBL # BEGIN { FS = "[ \t:]+"; n = 0; while( getline < "/etc/hosts" ) { host[n] = $2; addr[n] = $1; n++; } } function lookupHost( h ) { for( i = 0; i < n; i++ ) { if( host[i] == h ) { return addr[i]; } } return "0.0.0.0"; } /^[^\#]/ { ip = lookupHost($7); if( ip != "0.0.0.0" ) { printf( "%s.%s.%s.%s.%s.%s %s\n", $1, $2, $3, $4, $5, $6, ip ); } }