Bird
0
0

Which of the following is the correct syntax to loop from 1 to 10 in Bash using brace expansion?

easy📝 Syntax Q12 of 15
Bash Scripting - Loops
Which of the following is the correct syntax to loop from 1 to 10 in Bash using brace expansion?
Afor i in {1..10}; do echo $i; done
Bfor i in [1..10]; do echo $i; done
Cfor i in (1..10); do echo $i; done
Dfor i in <1..10>; do echo $i; done
Step-by-Step Solution
Solution:
  1. Step 1: Identify correct brace expansion syntax

    Bash uses curly braces {start..end} for ranges, so {1..10} is correct.
  2. Step 2: Check other options for syntax errors

    Parentheses, square brackets, and angle brackets are invalid for this purpose in Bash loops.
  3. Final Answer:

    for i in {1..10}; do echo $i; done -> Option A
  4. Quick Check:

    Brace expansion uses curly braces {..} [OK]
Quick Trick: Use curly braces {start..end} for ranges in Bash loops [OK]
Common Mistakes:
MISTAKES
  • Using parentheses or brackets instead of braces
  • Missing the 'in' keyword
  • Forgetting to close the loop with 'done'

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Bash Scripting Quizzes