Monday, March 9, 2009
About linux command "awk"
I just want to capture the mac address of NAT machine in order to control client PCs by script or to do ipfw bandwidth restrictions, I've looked a little awk usage, although has been used before, but i have forgot how to use this command for as long as while, Now, i will uset use arp to look up the current ip address and mac address first, and then use awk command to display the column containing 192 of the 1 and 3 columns, then you will get which ip address and mac addresss, if I used output command > that will output into a file then control many things by the way!
Example:
Example:
# arp
Address HWtype HWaddress Flags Mask Iface
192.168.2.1 ether 00:16:B6:D4:A5:7B C eth0
192.168.234.254 ether 00:00:0C:07:AC:00 C eth1
# arp|awk ‘/192/{print $1,$3}’
192.168.2.1 00:16:B6:D4:A5:7B
192.168.234.254 00:00:0C:07:AC:00


df