How does the range {1..5} work in the script?

QuestionsQuestions8 SkillsProBash Scripting LoopsSep, 12 2025
0112

In Bash, the range {1..5} is a brace expansion that generates a sequence of numbers from 1 to 5. It can be used in loops or commands to iterate over that range. For example:

for i in {1..5}; do
  echo "Number: $i"
done

This script will output:

Number: 1
Number: 2
Number: 3
Number: 4
Number: 5

The {1..5} syntax is a convenient way to create a list of numbers without needing to explicitly define them.

0 Comments

no data
Be the first to share your comment!