I want to get a mac address from arp table by using ip address. Currently I am using this command
arp -a $ipAddress | awk '{print $4}'
This command prints what I want. But I am not comfortable with it and I wonder if there is any built-in way or more stable way to do this.
You can parse the
/proc/net/arpfile usingawk:but I’m not sure it’s simpler (it saves one fork and a subshell, though).
If you want a 100% bash solution: