Need help on output

Guys please help me with my script.

HEre is my script.

#!/bin/bash
# Set up limit below
NOTIFY="5.0"

# CPU Usage every minute
TOP="$(top -b -n2 -d 00.20 |grep Cpu|tail -1 | awk -F ":" '{ print $2 }' | cut -d, -f1 | cut -d'%' -f1)"

# if load >= 5.0 create a file /home/scripts/loadavg.txt
if [ '$TOP -ge $NOTIFY' ]; then
echo $TOP "Warning!! CPU usage is above treshold" >> /home/scripts/loadavg.txt
fi

This should generate a texfile when the $TOP is greater than $Notify. But the thing is even if its not below 5.0 it still creating a file.

see below

[root@localhost scripts]# sh -x cpu_alert
+ NOTIFY=5.0
++ top -b -n2 -d 00.20
++ grep Cpu
++ tail -1
++ awk -F : '{ print $2 }'
++ cut -d, -f1
++ cut -d% -f1
+ TOP=' 0.0'
+ '[' '$TOP -ge $NOTIFY' ']'
+ echo 0.0 'Warning!! CPU usage is above treshold'

Thanks in advance

BASH does not support numbers with decimal places.

You can get the CPU use for the last minute much, much, much easier than top | awk | sed | cut | grep | kitchen | sink. The first three tokens from /proc/loadavg are the load average for the last minute, the last 5 minutes, and the last hour.

# Read all the stuff we want from /proc/loadavg
read LASTMIN LAST5MIN LASTHOUR OTHERSTUFF </proc/loadavg

# Convert 0.90 into 90.
#
# The shell interprets leading zeros as OCTAL, so we can't just feed 090 into
# it and get a sane result.  We shove a 1 onto the front to get 1090, then
# subtract 1000.
LASTMIN=$((1${LASTMIN/./} - 1000))

if [ "$LASTMIN" -gt 50 ]
then
        echo "Load average for last 5 minutes higher than 5.0"
fi