bash - Extracting MAC Address from arp table using grep regex -
i trying extract mac address arp table without returning empty line.
i tried use command:
arp -a | grep eth1 | grep '^\a(([0-9a-fa-f]{2}):){5}([0-9a-fa-f]{2})$\z'
the 'arp -a' command return:
? (192.168.36.20) @ 80:e0:1d:43:b0:60 [ether] on eth1 ? (192.168.0.1) @ 34:4b:50:b7:ef:08 [ether] on usb0 ? (172.17.140.200) @ 10:c3:7b:c4:82:04 [ether] on eth0
thanks
solved using:
arp -a | grep eth1 | grep -o -e '([[:xdigit:]]{1,2}:){5}[[:xdigit:]]{1,2}'
Comments
Post a Comment