Quick bash script I did for getting result from a MySQL query. It gets a number value from a database and if the number is less than (-lt) it executes another command. You can substitute -lt for -gt (greater than) as required. There are two versions the first executes a command on both pass and fail the second only reports on fail.
Version 1
#!/bin/bash
connections=$(mysql database -se "select count from nodes where status='1';")
if [ $connections -lt 200 ];
then echo "ERROR"
else echo "OK"
fi
Version 2
#!/bin/bash
connections=$(mysql database -se "select count from nodes where status='1';") if [ $connections -lt 200 ];
then echo "ERROR"
fi