View Full Version : OS X Version From Command Line
Hi,
How can I get the OS X version from the command line...?
I know how to get the Kernel Version via Uname, but not the OS X version...
Thanks...!
bramley
09-12-2006, 09:00 AM
http://forums.macosxhints.com/showthread.php?t=18697
guardian34
09-12-2006, 09:00 AM
Try this…
system_profiler SPSoftwareDataType
Edit: Didn't know that one bramley, thanks for the link.
Edit: If you want to, you can get it down to just the version numbers.
sw_vers | grep 'ProductVersion:' | grep -o '[0-9]*\.[0-9]*\.[0-9]*'
tlarkin
09-12-2006, 09:43 AM
wow in this reguard os x is very different from linux, that is why i was hesitant to respond until after i had looked it up, but didnt have time.
dmacks
09-12-2006, 10:19 AM
The usual "uname" is still present, but (as usual) that gives kernel info (something like "darwin 8.4.0"). Vendor/distribution system info is always a vendor/distribution-specific thing: need the OS X way for OS X, probably some rpm command tells you your redhat version info, etc.
guardian34
09-12-2006, 10:35 AM
I think the kernel version numbers coincide with the OS X version number (e.g. 10.4.7 has 8.7.0, and 10.5.1 will likely have 9.1.0). I wouldn't depend on the number though, if I didn't have to. Also, if you're going to compare to an OS X number, it's easier to just get it that way (e.g. Use that second script I mentioned to see if the version is ≥ 10.4.3).
tlarkin
09-12-2006, 10:36 AM
I think it would be easier to just go to apple menu > about this mac unless you already are working in the terminal
ElectricSheep
09-12-2006, 11:04 AM
I think it would be easier to just go to apple menu > about this mac unless you already are working in the terminal
Which is the fine and dandy obvious solution, unless you are working through a remote session via ssh or are writing a non-applescript script.
tlarkin
09-12-2006, 02:30 PM
ya, i had mentioned already working in the terminal.
guardian34
09-12-2006, 03:04 PM
tlarkin, there's a high chance of terminal usage in this particular forum. ;)
voldenuit
09-12-2006, 03:45 PM
I don't quite get the point of this thread after guardians solution:
sw_vers | grep 'ProductVersion:' | grep -o '[0-9]*\.[0-9]*\.[0-9]*'
That should solve the problem even for hard-core shell-scripters.
jpclark49
12-11-2009, 09:03 PM
For anyone who finds this in the "modern" era, try:
sw_vers -productVersion
It'll give you the number without doing any grep.
gerardw
12-16-2009, 09:08 AM
Thanks for the update -- needed to do this today.
renaultssoftware
01-05-2010, 07:05 PM
Try osascript -e 'system version of (system info)'
Hal Itosis
01-05-2010, 07:58 PM
Try osascript -e 'system version of (system info)'
Yeah that "works"... about *30* times slower:
$ time sw_vers -productVersion; echo; time osascript -e 'system version of (system info)'
10.5.8
real 0m0.027s
user 0m0.010s
sys 0m0.010s
10.5.8
real 0m1.029s
user 0m0.206s
sys 0m0.058s
Use osascript only when advantageous or necessary.
fluerty09
01-06-2010, 01:47 AM
you could envoke putty from its command line or simply write your own program to remotely execute commands.
Hal Itosis
01-06-2010, 01:46 PM
you could envoke putty from its command line or simply write your own program to remotely execute commands.
$ type -a putty
-bash: type: putty: not found
$ man putty
No manual entry for putty
$ Ach du lieber
-bash: Ach: command not found
:cool:
vBulletin® v3.8.7, Copyright ©2000-2012, vBulletin Solutions, Inc.