On Tuesday 12 December 2006 09:20, Chris Carey wrote:
> I need to write a function to search dhcpd.leases file to find IP
> addresses (I have the corresponding MAC address). This would be easy
> for me if the file had each lease on one line. In that case I could
> just grep for the MAC address , then parse out the IP address.
> However, the IP address is 5 lines above the said MAC address:
>
> lease 10.10.32.209 {
> starts 1 2006/12/11 19:04:32;
> ends 2 2006/12/12 19:04:32;
> binding state active;
> next binding state free;
> hardware ethernet 00:02:a1:1a:9c:94;
> uid "\001\000\002\241\032\234\221";
> }
grep -B 5
eg:
grep -B 5 <mac addr> |
grep '\(lease\|hardware.*ethernet\)'
or use awk ;)
/*
PLUG: http://plug.org, #utah on irc.freenode.net
Unsubscribe: http://plug.org/mailman/options/plug
Don't fear the penguin.
*/