I have to write a piece of code which compares the available disk space with a pre-defined value and takes further actions based on comparison.
AVAILSIZE=$(df | head -n 2 | tail -n 1 | awk '{ print $4 }' | sed 's/G//')
if [[ $AVAILSIZE -lt 7.0 ]]
then
    echo "[INFO] Not enough disk space available. Proceeding with cleanup..."
else
    echo "[INFO] Enough disk space available. Skipping cleanup."
fi
I have written this code. But the problem here is, "AVAILSIZE" is a float number and executing above throws error "-bash: [[: 3.7: syntax error: invalid arithmetic operator (error token is ".7")".
I tried using bc command but it throws another error "-bash: bc: command not found".
Please help with this. Or may be suggest another approach doing what I intent to.
Edit 1:
This is my df command output. I am interested in value 3.7G from first Filesystem result. Variable AVAILSIZE will have 3.7 value in it.
Filesystem                                  Size  Used Avail Use% Mounted on
/dev/mapper/cl_p10--centos7--template-root   16G   13G  3.7G  78% /
devtmpfs                                    1.9G     0  1.9G   0% /dev
tmpfs                                       1.9G     0  1.9G   0% /dev/shm
tmpfs                                       1.9G  185M  1.7G  10% /run
 
    