What if you could tell your computer to do repetitive tasks for you with just one simple command?
Why for loop with range ({1..10}) in Bash Scripting? - Purpose & Use Cases
Imagine you need to print numbers from 1 to 10 one by one in your terminal. Doing this manually means typing each number and command separately, which is tiring and boring.
Typing commands for each number wastes time and can cause mistakes like skipping numbers or typing wrong commands. It's slow and not fun, especially if you want to do it many times.
The for loop with range ({1..10}) lets you write a simple command that automatically repeats actions for numbers 1 through 10. It saves time and avoids errors by doing the counting for you.
echo 1 echo 2 echo 3 ... echo 10
for i in {1..10}; do echo $i; done
This lets you quickly repeat tasks many times without extra typing, making your work faster and less error-prone.
Say you want to create 10 folders named folder1 to folder10. Instead of making each folder one by one, a for loop does it all in seconds.
Manual repetition is slow and error-prone.
For loop with range automates repeated actions easily.
It saves time and reduces mistakes in scripts.