Open
Description
$ sw_vers
ProductName: Mac OS X
ProductVersion: 10.14.6
BuildVersion: 18G9028
struct utsname name;
if (uname(&name) == 0) {
printf("os.name=%s\n",name.sysname);
printf("os.version=%s\n",name.release);
}
// os.name=Darwin
// os.version=18.7.0
Seems no way to map Darwin version to Mac OS X version.
/usr/libexec/PlistBuddy -c "Print:ProductName" \
-c "Print:ProductVersion" \
-c "Print:ProductBuildVersion" /System/Library/CoreServices/SystemVersion.plist
Mac OS X
10.12.6
16G2128
That is an XML file but it may be best to just read that file.