Get the UUID for a Mac with ioreg

UUIDs, used throughout the rest of Mac OS X for identifying disks and users and groups and whatnot, have now become the unique identifier for ByHost preferences. Or so I’ve been informed, in this+article+on+the+topic+at+AFP548, which told me that Ethernet hardware addresses are no longer en vogue for this purpose in Leopard.

So, to get the UUID for your Mac you can do the following step suggested in the article:

$ ioreg -rd1 -c IOPlatformExpertDevice | grep -E '(UUID)'
"IOPlatformUUID" = "10703BFC-6664-40C5-9331-E73FCE2C2E29"

Let’s expand upon this for a moment. Switch that grepping over to awk, and you get:

$ ioreg -rd1 -c IOPlatformExpertDevice | awk '/IOPlatformUUID/ { print $3; }'

Note that you can strip the quotes in the same manner I did with serial numbers from ioreg:

$ ioreg -rd1 -c IOPlatformExpertDevice | awk '/IOPlatformUUID/ { split($0, line, "\""); printf("%s\n", line[4]); }'

Well, that’s it. I’m not going to launch into any long performance analysis of this … at least, not right now.