Skip to content

Instantly share code, notes, and snippets.

@mattfinlayson
Created March 20, 2015 22:13
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mattfinlayson/478a82696225acba0edd to your computer and use it in GitHub Desktop.
Save mattfinlayson/478a82696225acba0edd to your computer and use it in GitHub Desktop.
Bash for determining OS X Version (Mavericks)
#!/bin/bash -x
DARWINOS_MAJOR=`sysctl -n kern.osrelease | cut -d . -f 1`
DARWINOS_MINOR=`sysctl -n kern.osrelease | cut -d . -f 2`
OS_X_MAJOR="10" # For context
OS_X_MINOR=`echo ${DARWINOS_MAJOR}-4 | bc` # Magic apple convention
OS_X_REVISION="${DARWINOS_MINOR}" # For completeness
OS_X_VERSION="${OS_X_MAJOR}.${OS_X_MINOR}.${OS_X_REVISION}"
if [ "${OS_X_MINOR}" -ge "10" ]; then
echo "Mavericks"
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment