Simple question:
How to get the MAC address of an active Ethernet connection in a bash script?
I currently have:
set - `/sbin/ifconfig eth0 | head -1` MAC=$5
Which outputs the MAC address of eth0, but if eth1 is active, I want this instead.
Can I pre-execute ifconfig | grep inet ifconfig | grep inet , but that will not tell me which interface is active, only that one is active. I need to capture the line above it to tell me which one is the active connection.
Any help would be greatly appreciated.
Thanks!
source share