mercredi 29 juin 2016

Bash if/else Loop Error

Exactly as title says. Simple for loop in Bash. I've been trying to figure out why this loop isn't working and I haven't come up with anything for two days now. Insight would be appreciated.

declare -r TIMESTAMP=$(date "+%Y-%m-%d %H:%M:%S,%3N)

CHECK="$(grep -c "$TIMESTAMP" /var/log/host/logname.log)"
if [ "$CHECK" -eq 0 ]
then
     COLOR="green"
elif [ 0 -lt "$CHECK" ] && [ "$CHECK" -le 5 ]
     COLOR="yellow"
else
     COLOR="red"
fi

The COLOR var is something that is preset by the system I'm using. The red/yellow/green are all correct, something in either my syntax or logic is the issue, though I've been struggling to determine which. Thanks!

Aucun commentaire:

Enregistrer un commentaire