There are a few ways to determine what version of OSX you are on.
In the GUI, you can easily click the 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. There are several ways:
1.9.2 kevin-macbookpro:~ $ system_profiler SPSoftwareDataType Software: System Software Overview: System Version: Mac OS X 10.7.4 (11E53) Kernel Version: Darwin 11.4.0 Boot Volume: San Francisco Boot Mode: Normal Computer Name: Kevin Elliott’s MacBook Pro User Name: Kevin Elliott (kevin) Secure Virtual Memory: Enabled 64-bit Kernel and Extensions: Yes Time since boot: 1 day12:47
1.9.2 kevin-macbookpro:~ $ sw_vers ProductName: Mac OS X ProductVersion: 10.7.4 BuildVersion: 11E53
Mac OS X user defaults system
1.9.2 kevin-macbookpro:~ $ defaults read loginwindow SystemVersionStampAsString 10.7.4
There are further options but they are not as optimized and simple to use. These should be sufficient!