In Red Hat the file /etc/redhat-release contains the operating system version data (such as "Red Hat release X.X (Final)").

Is there any similar mechanism in Mac OS X that can be used programatically to get the operating system version data (such as "Mac OS X 10.5.8")?

link|improve this question

feedback

2 Answers

up vote 3 down vote accepted

In case you are looking for more details to the kernel, you can also query the sysctl interface which provides the kernel ostype, version and other details.

  • To get the ostype : sysctl kern.ostype
  • To get the osversion : sysctl kern.osversion
  • To get the version : sysctl kern.version
  • To get the osrevision : sysctl kern.osrevision

More details here : http://developer.apple.com/mac/library/documentation/Darwin/Reference/ManPages/man8/sysctl.8.html

link|improve this answer
1  
Just FYI: On Ubuntu, it's "kernel" instead of "kern". And for these keys, the output is the same as uname -a (or the various subsets from other options like -s, -r, -v, etc.) – Dennis Williamson Sep 6 '09 at 22:01
1  
uname -a on a Mac: "Darwin <machine name>.local 9.8.0 Darwin Kernel Version 9.8.0: Wed Jul 15 16:55:01 PDT 2009; root:xnu-1228.15.4~1/RELEASE_I386 i386" – warren Sep 7 '09 at 3:21
feedback

Found the answer:

/usr/bin/sw_vers
link|improve this answer
feedback

Your Answer

 
or
required, but never shown

Not the answer you're looking for? Browse other questions tagged or ask your own question.