OS_Version (полный… пример 10.7.3)
system_profiler SPSoftwareDataType | grep "System Version" | awk '{print $6}'
ИЛИ
sw_vers -productVersion
ОС (короткий… пример 10.7)
system_profiler SPSoftwareDataType | grep "System Version" | awk '{print $6}' | sed "s:.[[:digit:]]*.$::g"
ИЛИ
OS_Version=$(OS (short… example 10.7) | sed "s:.[[:digit:]]*)
Баш:
#!/bin/bash
# Use one of the examples given above to create the OS_Version variable
if [[ ${OS_Version} == 10.7.3 ]]; then
echo "Operating System is a match... will continue on."
else
echo "Operating System is NOT a match... will NOT continue."
fi