I have a simple script which displays current memory usage, disk usage, and CPU load within a terminal. Here is the code so you can see what I mean:free -m | awk 'NR==2{printf  | Memory Usage: %s/%sMB (%.2f%%)|\n, $3,$2,$3*100/$2 }'df -h | awk '$NF==/{printf  | Disk Usage: %d/%dGB (%s) |\n, $3,$2,$5}'top -bn1 | grep load | awk '{printf  | CPU Load: %.2f |\n, $(NF-2)}'The problem is that it only runs that code within the script 1 time. I need to automatically keep running that script every 1 second without having to keep reloading the script. So basically I just want it in some sort of continuous loop while the script can do other stuff. The reason I want it to continue to refresh every 1 second, is because it only shows the CPU usage 1 time right when you run the script, but CPU changes frequently, so I need it to keep displaying current data.
How to keep code running whitin a script
bash;shell script;scripting