Bash monitor CPU & RAM

I’ve made a nice simple little #bash script that can you monitor your #Linux CPU and Memory from command line in a loop when running some heavy load using the simple top command.

Code:

#!/usr/bin/env bash
#
while true; do 
clear; 
echo CPU - $(top -b -n 1 | grep "Cpu(s)" | sed "s/.*, *\([0-9.]*\)%* id.*/\1/" | awk '{print 100 - $1"%"}'); 
echo MEM - $(top -b -n 1 | grep "MiB Mem" | awk 'FNR == 1 {print $8/($8+$6)*100}'| cut -c1-5)%;
sleep 10; 
done
#