From the Terminal, or an SSH session, how can I find the version of my OS?
Run the command: sw_vers
sw_vers
The command outputs 3 lines: ProductName, ProductVersion, and BuildVersion. If you wish to get just one of them, you can use one of these:
sw_vers -productName
sw_vers -productVersion
sw_vers -buildVersion
For example:
bash-3.2$ sw_vers ProductName: Mac OS X ProductVersion: 10.11.6 BuildVersion: 15G1421