0
0
Bash Scriptingscripting~20 mins

Brace expansion ({1..10}) in Bash Scripting - Practice Problems & Coding Challenges

Choose your learning style9 modes available
Challenge - 5 Problems
🎖️
Brace Expansion Master
Get all challenges correct to earn this badge!
Test your skills under time pressure!
💻 Command Output
intermediate
1:00remaining
Output of simple brace expansion
What is the output of the following bash command?
echo {1..5}
Bash Scripting
echo {1..5}
A1,2,3,4,5
B{1..5}
C1 2 3 4 5 6
D1 2 3 4 5
Attempts:
2 left
💡 Hint
Brace expansion generates a sequence of numbers separated by spaces.
💻 Command Output
intermediate
1:00remaining
Brace expansion with step value
What is the output of this bash command?
echo {1..10..3}
Bash Scripting
echo {1..10..3}
A1 4 7
B1 4 7 10
C1 3 6 9
D1 2 3 4 5 6 7 8 9 10
Attempts:
2 left
💡 Hint
The third number in brace expansion is the step size.
📝 Syntax
advanced
1:30remaining
Identify invalid brace expansion syntax
Which of the following is NOT a valid brace expansion in bash?
Aecho {5..1}
Becho {1..10..2}
Cecho {1..10..0}
Decho {a..z}
Attempts:
2 left
💡 Hint
Step value cannot be zero in brace expansion.
💻 Command Output
advanced
1:30remaining
Output of nested brace expansion
What is the output of this bash command?
echo file{1..3}_{a..b}.txt
Bash Scripting
echo file{1..3}_{a..b}.txt
Afile1_a.txt file1_b.txt file2_a.txt file2_b.txt file3_a.txt file3_b.txt
Bfile1_a.txt file2_b.txt file3_a.txt
Cfile{1..3}_{a..b}.txt
Dfile1_a.txt file1_b.txt file2_a.txt file3_b.txt
Attempts:
2 left
💡 Hint
Brace expansions combine all possible pairs from each set.
🚀 Application
expert
2:00remaining
Count files created by brace expansion
If you run this command:
touch log_{01..10}_{a..c}.txt

How many files will be created?
Bash Scripting
touch log_{01..10}_{a..c}.txt
A30
B33
C20
D13
Attempts:
2 left
💡 Hint
Multiply the count of numbers by the count of letters.