Wednesday, 10 June 2020

MacOSx version from the command line

I have some old disks lying around and in "These Uncertain Times" (TM) was going through them to catalog with Neofinder (stunningly good application for cataloging all sorts of things and especially for offline disks/CDs etc.  Check it out at: https://www.cdfinder.de - unpaid promotion)

One of my disks looks to have a Carbon Copy Cloner backup of an old version of the OS.  I wanted to know which release it was, but realised I didn't know how to under MacOS. The normal Unix-y things of /etc/motd /etc/red-hat-release, etc don't exists as such,  After a few minutes looking around I found the following:

  • The command sw_vers is a command to print out the version of the running OS.
  • The man page for sw_vers refers to /System/Library/CoreServices/SystemVersion.plist
I could just dump the file, but after a few minutes looking at the file, I worked out the following:

  • /usr/libexec/PlistBuddy -c "Print:ProductName" -c "Print:ProductVersion"  -c "Print:ProductBuildVersion" /System/Library/CoreServices/SystemVersion.plist
and by extension:
  • /usr/libexec/PlistBuddy -c "Print:ProductName" -c "Print:ProductVersion"  -c "Print:ProductBuildVersion" /Volumes/Unknown-disk/System/Library/CoreServices/SystemVersion.plist
printed the MacOS version of the disk image in question.

No comments:

Post a Comment