What is the best way to extract the MAC address from ifconfig\'s output?
ifconfig
Sample output:
bash-3.00# ifconfig eth0 eth0 Link
I needed to get MAC address of the active adapter, so ended up using this command.
ifconfig -a | awk '/^[a-z]/ { iface=$1; mac=$NF; next } /inet addr:/ { print mac }' | grep -o -E '([[:xdigit:]]{1,2}:){5}[[:xdigit:]]{1,2}'
Hope it helps.