Shell command for getting mac address in OS X

ifconfig en1 gets the interface details for wifi, the mac is on a line starting with ether, and is the second word on that line so:

ifconfig en1 | awk '/ether/{print $2}'

I think the best and easiest way to get the information is using this command:

networksetup -listallhardwareports

It will return a nice list of devices like this:

Hardware Port: USB 10/100/1000 LAN
Device: en6
Ethernet Address: 00:e0:4c:...

Hardware Port: Wi-Fi
Device: en0
Ethernet Address: 80:e6:50:...

Hardware Port: Bluetooth PAN
Device: en3
Ethernet Address: 80:e6:50:...

Hardware Port: Thunderbolt 1
Device: en1
Ethernet Address: 72:00:05:...

Hardware Port: Thunderbolt 2
Device: en2
Ethernet Address: 72:00:05:...

Hardware Port: Thunderbolt Bridge
Device: bridge0
Ethernet Address: 72:00:05:...

VLAN Configurations
===================

networksetup -getmacaddress <interface>