In many administration scripts, you need to check the version of macOS, to make sure you don’t try to access features that are not present on other versions.
The first part of the version number (“major” version) is always
10(so far). The second part (“minor” version) denotes the version of macOS (
11: El Capitan,
13: High Sierra, etc.) and the third (“patch” or update version) the update number. (Useful list of macOS versions and names on Wikipedia.)
Aside from the numerical version number or product version, macOS also has a build number, which follows a different schema. The first part is a number which matches the “Darwin version” of macOS. Mac OS X 10.0 had a Darwin version of 4 and that number has increased with every version of Mac OS X. Currently, macOS High Sierra 10.13 has a Darwin version of 17. Then follows a single capital letter, with A being the first release of a version (i.e the 10.x.0 version), B is the first patch update (10.x.1) and so on.).
Made up a little graphic to explain macOS versions, in case it's useful. You can programmatically compare if you split the string right. pic.twitter.com/tBhhwwt15n
— Elliot Jordan (@homebysix) 30. November 2017