I want to extract IP of machine leonidas. arp -a returns such line (among others):
leonidas.home (192.168.1.5) at 0:1c:c0:de:8f:28 on en1 ifscope [ethernet]
To have only IP:
arp -a | grep leonidas | cut -f 2 -d ' ' | sed 's/[()]//g'
prints
192.168.1.5
4 comments:
easier way:
arp | grep wlan0 | awk '{print $1}'
use host name rather than interface name
Post a Comment