I'm working on a script to wake different LCs on my LAN. MAC-Adresses are hard to memorize so I made myself a list that contains information about the respective PCs. Right now the list looks like:
dragoner xxx.xxx.xxx.xxx xx:xx:xx:xx:xx:xx
theseus yyy.yyy.yyy.yyy yy:yy:yy:yy:yy:yy
...
That means, that new entries will always have to be in the form: netbios-name ipv4 mac
. The advantage is, that such a list can easily be queried by grep
and awk
.
I'd rather like to have a list like that:
netbios=dragoner ip4=xxx.xxx.xxx.xxx mac=xx:xx:xx:xx:xx:xx
netbios=theseus mac=yy:yy:yy:yy:yy:yy ip4=yyy.yyy.yyy.yyy
...
In that manner new information could be added more easily and row wouldn't have to have a certain number of columns... but I'm failing to query it via awk.
In either list format you should be able to just search it. I'm not sure what you're trying to do past simple lookups but thanks to their relative formats, MAC addresses are always going to contain
:
, IPs.
and netbios should be clean of both.What doesn't
grep '1.2.3.4' mylist
do?And you could be really bashy about this and do something like:
Or, don't use awk, use bash