Is there a way to get OSX codename (I.e. Yosemite, El Capitan etc) from command line?
I'm not looking for Version information (e.g.
sw_vers -productVersion
) which gives 10.10 etc
Thanks!
osx
Is there a way to get OSX codename (I.e. Yosemite, El Capitan etc) from command line?
I'm not looking for Version information (e.g.
sw_vers -productVersion
) which gives 10.10 etc
Thanks!
Best Answer
I'm sure there's got to be an easier and more-reliable way, but at least you can eliminate the pipe to
sed
altogether by usinggrep
with-o
(prints only matches) and-E
(extended regular expressions):This does, however, also return the
SOFTWARE LICENSE AGREEMENT FOR OS X
portion of the output. If you just want the codename, you could pipe it to sed, but it would not require any back-references using the dreaded-E
flag that BSDsed
is so infamous for:Personally, I prefer the
awk
method instead:Pure
awk
solution:(I'm sure there's a way to do it without piping to additional awk processes, but I'm not a pro.)