Page 1 of 1
Forum

Welcome to the Tweaking4All community forums!
When participating, please keep the Forum Rules in mind!

Topics for particular software or systems: Start your topic link with the name of the application or system.
For example “MacOS X – Your question“, or “MS Word – Your Tip or Trick“.

Please note that switching to another language when reading a post will not bring you to the same post, in Dutch, as there is no translation for that post!



MacOS X - How to de...
 
Share:
Notifications
Clear all

[Solved] MacOS X - How to determine OS version from Terminal

2 Posts
1 Users
0 Reactions
2,366 Views
 Hans
(@hans)
Famed Member Admin
Joined: 12 years ago
Posts: 2859
Topic starter  

For a little project I'm working on, I had to figure out which MacOS version my computer was running from Terminal (command line).

Took a bit of searching, but I finally found this trick:

sw_vers 

Which produces an output like this for macOS Sierra:

ProductName:	Mac OS X
ProductVersion: 10.12.2
BuildVersion: 16C67

If you only want one of these items:

~ hans$ sw_vers -buildVersion
16C67 ~ hans$ sw_vers -productName
Mac OS X ~ hans$ sw_vers -productVersion
10.12.2


   
ReplyQuote
 Hans
(@hans)
Famed Member Admin
Joined: 12 years ago
Posts: 2859
Topic starter  

Alternatives:

defaults read "$3/System/Library/CoreServices/SystemVersion"

produces:

{
    ProductBuildVersion = 16C67;
    ProductCopyright = "1983-2016 Apple Inc.";
    ProductName = "Mac OS X";
    ProductUserVisibleVersion = "10.12.2";
    ProductVersion = "10.12.2";
}

and:

defaults read loginwindow SystemVersionStampAsString

results in:

10.12.2

and:

system_profiler SPSoftwareDataType

resulteert in:

gives you:

Software:
    System Software Overview:
      System Version: macOS 10.12.2 (16C67)
      Kernel Version: Darwin 16.3.0
      Boot Volume: Macintosh HD
      Boot Mode: Normal
      Computer Name: Hans’s MacBook Pro
      User Name: Hans Luijten (hans)
      Secure Virtual Memory: Enabled
      System Integrity Protection: Enabled
      Time since boot: 23:40

and another one:

cat /System/Library/CoreServices/SystemVersion.plist

lists:

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
 <key>ProductBuildVersion</key>
 <string>16C67</string>
 <key>ProductCopyright</key>
 <string>1983-2016 Apple Inc.</string>
 <key>ProductName</key>
 <string>Mac OS X</string>
 <key>ProductUserVisibleVersion</key>
 <string>10.12.2</string>
 <key>ProductVersion</key>
 <string>10.12.2</string>
</dict>
</plist>

   
ReplyQuote
Share: