Infinite Loops in Bash Scripting
📖 Scenario: You are learning how to create loops in Bash scripts. Loops help you repeat tasks automatically, like checking if a file exists or waiting for user input. Sometimes, you want a loop to run forever until you stop it manually. This is called an infinite loop.Imagine you want to create a simple script that keeps printing a message every second until you stop it. This is useful for monitoring or waiting for something to happen.
🎯 Goal: Build a Bash script that uses an infinite loop to print the message "Hello, world!" every second.
📋 What You'll Learn
Create an infinite loop using the correct Bash syntax
Use the
echo command to print the messageUse the
sleep command to pause for 1 second between printsPrint the message repeatedly until the script is stopped manually
💡 Why This Matters
🌍 Real World
Infinite loops are used in scripts that monitor system status, wait for events, or run servers that need to stay active until stopped.
💼 Career
Understanding infinite loops is important for automation, system administration, and writing scripts that handle continuous tasks or services.
Progress0 / 4 steps