How to Determine Mac OS version from Command Line

There are a few ways to determine what version of OSX you are on.

In the GUI, you can click the on Apple menu () at the top left of your screen, and choose About This Mac. The version of OS X will be printed underneath the large bold Mac OS X title. Clicking on the Version XYZ text will reveal the Build number.

If you’re writing a script though, you may wish to access this programmatically. To do this, type:

$ system_profiler SPSoftwareDataType
Software:

    System Software Overview:

      System Version: macOS 10.12.6 (16G29)
      Kernel Version: Darwin 16.7.0
      Boot Volume: Macintosh HD
      Boot Mode: Normal
      Computer Name: Srini’s MacBook Pro
      User Name: Srini Karlekar (skarlekar)
      Secure Virtual Memory: Enabled
      System Integrity Protection: Enabled
      Time since boot: 21 days 8:30

$