free -m | head-n 2 | tail-n 1 | awk{'print $4'}# could be, like you use in CPU idle
free -m | sed-n 2p | awk'{print $4}'# but more simply
free -m | awk'NR == 2 {print $4}'
free -m | tail-n 1 | awk{'print $3'}# like you do with free space
free -m | awk'END {print $3}'
df-h / | awk'{ a = $4 } END { print a }'# You don't need to store a variable heredf-h / | awk'END { print $4 }'
You've got a few possible improvements in here.
Here's what I found.
Thanks on pointing that out, I'll edit script with your improvements.