What if your computer could keep working for you, nonstop, without you lifting a finger?
Why Infinite loops in Bash Scripting? - Purpose & Use Cases
Imagine you need to keep checking if a file has been updated on your computer. Doing this by hand means constantly looking at the file, over and over, without stopping.
Manually watching for changes is tiring and easy to forget. You might miss updates or waste time checking when nothing has changed. It's slow and boring.
Using an infinite loop in a script lets the computer keep checking automatically, again and again, without you needing to do anything. It runs until you tell it to stop.
Check file, wait, check again, repeat manually
while true; do check file; sleep 5; done
Infinite loops let your scripts watch or repeat tasks endlessly, freeing you from constant manual work.
A script that keeps monitoring a folder for new photos and automatically backs them up as soon as they appear.
Manual repeated checks are slow and error-prone.
Infinite loops automate continuous tasks effortlessly.
They keep scripts running until you decide to stop them.