Can anyone tell me what I'm doing wrong? I'm trying to write a script that checks the version of macOS so I can have it trigger a Jamf policy based on the version of macOS that the computer is running. I wanted to account for all versions of Sonoma and all versions of Ventura. I keep getting "integer expression expected" errors. I used shellcheck.net and it didn't find any problems. I'm testing this in CodeRunner. I also tested it in Terminal. I thought I knew how to do this! I have even looked at some other scripts that I have that use similar syntax. They work.
#!/bin/zsh
macOSVersion=$(/usr/bin/sw_vers | grep "ProductVersion" | /usr/bin/awk '{ print $2 }')
echo "$macOSVersion"
if [ "$macOSVersion" -ge 14 ] && [ "$macOSVersion" -lt 15 ]; then
echo "This Mac is running macOS Sonoma"
elif [ "$macOSVersion" -ge 13 ] && [ "$macOSVersion" -lt 14 ]; then
echo "This Mac is running macOS Ventura"
else
echo "This Mac is running a macOS earlier than Ventura"
fi