Skip to main content

How can I identify the macOS version from the command line? [Resolved]

After detecting a GNU/Linux system through running uname, in a GNU/Linux distribution lsb_release -a is a good entry level utility you could use to [try to] find out the GNU/Linux distribution name and particular version1.

After detecting a Darwin (possibly macOS) system through running uname, there must be a Different (maybe not that much...) way to Ask the OS version number1. Even if it only works on macOS, it'd be useful.

What have I done so far:

Search "Ask Different" "alternative to lsb_release". 0 results.

1: If developer wanted to act based upon this, which can be right, or wrong, or even horrible; but is not the topic.

Question Credit: john
Question Reference
Asked September 10, 2019
Posted Under: Apple
2 Answers

I don't know if all of this is imposed by Darwin, the manual page seems like it maybe is a Mac OS X (sic in my manual page as of Sep 2019) thing, but there is the awesome sw_vers:

$ sw_vers
ProductName:    Mac OS X
ProductVersion: 10.14.6
BuildVersion:   yadda yadda yadda
$ _

credit: john
Answered September 10, 2019

LSB stands for "Linux Standard Base".

macOS isn't Linux, so it isn't part of the LSB project, and doesn't support LSB tools.

credit: duskwuff
Answered September 10, 2019
Your Answer