Looking for a way to run a command depending on OS version I'm trying to create a bash script that runs a command based on OS version that way I can deploy it to machines running 10.12 and 10.13 the only problem is depending on the version the command needs to be slightly different.  How can I go about this?
You can get the OS version using sw_vers -productVersion.

$ sw_vers -productVersion
10.13.2


You can test on this in a shell script using

if [[ $(sw_vers -productVersion) == 10.13.2 ]]; then …


To test any 10.12 or 10.13 version, you can use parse the output such as with this

if [[ $(sw_vers -productVersion | sed "s/10\.\([0-9][0-9]\).*/\1/") == 13 ]]; then …