Você não pode expressar intervalos de números facilmente nas expressões case - o padrão [1000-9999] , por exemplo, não significa os números 1000 a 9999 , mas os caracteres 1 , 0 , 0 , o intervalo 0-9 , os caracteres 9 , 9 , 9 - essencialmente, todos os dígitos. [1-85] não significa os números 1 a 85 , mas os dígitos de 1 a 8 e 5 , ... que são apenas os dígitos de 1 a 8 . Portanto, [1-20]* significa qualquer coisa que comece com 1 , 2 ou 0 - então, mesmo 20000000 corresponderá a isso. Use if / then / elif / else / fi :
if (( $SECURITY_PACKAGES == 0 ))
then
echo "OK - not bad: There are a total of $TOTAL_PACKAGES packages to upgrade in this server, but none of them are security updates!"
exit 0
elif (( $SECURITY_PACKAGES <= 20 ))
then
echo "WARNING - $TOTAL_PACKAGES packages required to upgrade in this server, of which $SECURITY_PACKAGES are security updates"
exit 1
elif (( $SECURITY_PACKAGES <= 9999 ))
then
echo "CRITICAL - $SECURITY_PACKAGES out of $TOTAL_PACKAGES are security updates! Consider upgrading soon!"
exit 2
else
echo "UNKNOWN - I am not sure what's happening now, check later or check server: $TOTAL_PACKAGES to upgrade, $SECURITY_PACKAGES are security updates"
exit 3
fi