Just how can I inform what version of OS X I'm on from the command line?

I regularly locate myself SSHing right into numerous OS X equipments, and also it would certainly serve if I can inform what version of OS X I got on when I'm doing that. uname -a does not fairly function, given that Darwin bit versions do not constantly transform with the remainder of the system.

0
2019-05-06 22:02:24
Source Share
Answers: 4

Here is a Blog write-up with guidelines How to Get the Mac OS X Version in a Shell Script

OS_VERSION=`/usr/bin/defaults read "$3/System/Library/CoreServices/SystemVersion" ProductVersion`
echo "$OS_VERSION"
0
2019-05-08 18:48:01
Source

Try this :

 system_profiler  | grep 'System Version'

Mike Gray's solution is far better than this. Please see that

0
2019-05-08 18:41:25
Source

sw_vers

My pointer is to make use of sw_vers. Instance result since 10.6.4 :

> sw_vers 
ProductName:    Mac OS X
ProductVersion: 10.6.4
BuildVersion:   10F569

The solution that recommended system_profiler | grep 'System Version' is what I have actually attempted to make use of in the past, yet it has 2 troubles.

  1. It is slow-moving given that it creates a complete system_profiler dump of the equipment, collecting all software and hardware supply details.
  2. The result of system_profiler has actually transformed with time. as an example result of grep for 'Serial Number' on 10.6.4 is "Serial Number (system) : ZNNNNNZNZZZ", whereas on 10.4.11 it was "Serial Number : ZNNNNZNZZZZ" - relevance being the parse - capacity of the result and also the add" (system)" item can be bothersome unless you are anticipating the adjustment.
0
2019-05-08 08:18:41
Source

The most convenient means is :

$ sw_vers -productVersion
10.6.4

From http://tinyapps.org/blog/mac/201008140700_os_x_version_terminal.html :

$ sw_vers
ProductName:    Mac OS X
ProductVersion: 10.6.4
BuildVersion:  
10F569
$ sw_vers -productVersion
10.6.4

Specifically convenient when resetting a password in solitary customer setting, given that the method differs based upon which version of OS X is running.

0
2019-05-08 03:18:53
Source