I use a lot of scripts that involve the Mac addresses of my network cards. Is there a file I can read or a command that I can use to JUST get the Mac address? I don't want any headers or anything, just 1 line of output that has the Mac address. I would like to set this as an environment variable on login. I use Arch Linux x64
This works for me. Can probably be optimized a bit:
/sbin/ifconfig eth0 | grep -o 'HWaddr *[0-9A-F:]*' | sed -s 's/HWaddr *//'
I don't think you can simplify it much from this. I did an
strace on the ifconfig, and it seems you pull the MAC addr with an ioctl() on a socket, not from a /proc file.