Get OS Version From Scripts
It is sometimes useful to have a script check the OS version, for example the way to get the user’s full name was previously done using
niutil but Apple removed that command in Leopard (it can now be done using
One BSD command to read OS properties is
sysctl but prior to Leopard it didn’t offer
kern.osrelease making it a bit awkward, as you had to keep track of how
kern.osversion maps to a more humane number.
The manual page has no history, but the date is 2003 and an example in the manual page has
10.2.4 as output, so it goes way back.