How to get MacOS version by the command line

NAME
     sw_vers -- print Mac OS X operating system version information

SYNOPSIS
     sw_vers
     sw_vers -productName
     sw_vers -productVersion
     sw_vers -buildVersion

DESCRIPTION
     sw_vers prints version information about the Mac OS X or Mac OS X Server operating system running on the local machine.

     When executed with no options sw_vers prints a short list of version properties:

EXAMPLE:

  $ sw_vers 
  ProductName: Mac OS X
  ProductVersion: 10.10.3
  BuildVersion: 14D136