Never been to CodeSnippets before?

Snippets is a public source code repository. Easily build up your personal collection of code snippets, categorize them with tags / keywords, and share them with the world (or not, you can keep them private!)

Get your Mac's serial number (See related posts)

# cf. Mac OS X: About This Mac window provides computer serial number, http://support.apple.com/kb/HT1529
# http://www.tuaw.com/2005/04/14/when-was-your-mac-born/
# http://www.chipmunk.nl/klantenservice/applemodel.html

# sed will print & quit after the first match: ...p;q;}'
man sed | less -p '\[1addr\]q'

ioreg -c IOPlatformExpertDevice | grep IOPlatformSerialNumber | sed -n -e 'l' 

time -p /usr/sbin/ioreg -c IOPlatformExpertDevice | /usr/bin/sed -E -n -e '/IOPlatformSerialNumber/{s/^.* "IOPlatformSerialNumber" = "(.+)"$/\1/p;q;}'
time -p /usr/sbin/system_profiler SPHardwareDataType | /usr/bin/awk '/Serial Number/ {print $3}'


function serialnum() {
   /usr/sbin/ioreg -c IOPlatformExpertDevice | /usr/bin/sed -E -n -e '/IOPlatformSerialNumber/{s/^.*[[:space:]]"IOPlatformSerialNumber" = "(.+)"$/\1/p;q;}'
   return 0
}

serialnum
time -p serialnum



You need to create an account or log in to post comments to this site.