Counting Numbers with a Bash For Loop
📖 Scenario: Imagine you want to count from 1 to 10 using a simple script. This is like counting steps as you walk up a staircase.
🎯 Goal: You will write a Bash script that uses a for loop with a range {1..10} to print numbers from 1 to 10, one number per line.
📋 What You'll Learn
Create a Bash script variable to hold a greeting message.
Create a variable to hold the range of numbers from 1 to 10.
Use a
for loop with the range {1..10} to print each number.Print the greeting message before the numbers.
💡 Why This Matters
🌍 Real World
Counting or looping through numbers is common in scripts that automate tasks like backups, monitoring, or batch processing files.
💼 Career
Knowing how to use loops and ranges in Bash is a basic skill for system administrators, DevOps engineers, and anyone automating tasks on Linux or Unix systems.
Progress0 / 4 steps