Challenge - 5 Problems
File Globbing Master
Get all challenges correct to earn this badge!
Test your skills under time pressure!
💻 Command Output
intermediate1:30remaining
What files match this pattern?
Given a directory containing files:
What files will match the pattern
report1.txt, report2.txt, report_final.txt, summary.txt, data.csvWhat files will match the pattern
report?.txt?Attempts:
2 left
💡 Hint
The question mark matches exactly one character.
✗ Incorrect
The pattern
report?.txt matches files starting with 'report', followed by exactly one character, then '.txt'. So it matches 'report1.txt' and 'report2.txt' but not 'report_final.txt' because it has more than one character after 'report'.💻 Command Output
intermediate1:30remaining
Which files match the pattern with brackets?
In a folder with files:
Which files match the pattern
data1.csv, data2.csv, data3.csv, dataA.csv, dataB.csvWhich files match the pattern
data[12].csv?Attempts:
2 left
💡 Hint
Square brackets match exactly one character from the set inside.
✗ Incorrect
The pattern
data[12].csv matches files where the character after 'data' is either '1' or '2'. So it matches 'data1.csv' and 'data2.csv' only.📝 Syntax
advanced2:00remaining
Identify the correct glob pattern for matching files ending with .log or .txt
Which of the following patterns correctly matches files that end with either
.log or .txt?Attempts:
2 left
💡 Hint
Brace expansion is used to match multiple extensions.
✗ Incorrect
The pattern
*.{log,txt} uses brace expansion to match files ending with either '.log' or '.txt'. The other options use invalid syntax for globbing.💻 Command Output
advanced1:30remaining
What is the output of this glob pattern?
Given files:
What files match the pattern
file1.txt, file2.txt, file10.txt, file20.txt, fileA.txtWhat files match the pattern
file?.txt?Attempts:
2 left
💡 Hint
The question mark matches exactly one character.
✗ Incorrect
The pattern
file?.txt matches files with exactly one character after 'file' before '.txt'. So it matches 'file1.txt', 'file2.txt', and 'fileA.txt'. It does not match 'file10.txt' or 'file20.txt' because they have two characters after 'file'.🧠 Conceptual
expert2:30remaining
How many files match this complex pattern?
In a directory with files:
How many files match the pattern
a1.txt, a2.txt, a10.txt, b1.txt, b2.txt, c1.txtHow many files match the pattern
[ab]?*.txt?Attempts:
2 left
💡 Hint
The pattern matches files starting with 'a' or 'b', followed by at least one character, then any characters, ending with '.txt'.
✗ Incorrect
The pattern
[ab]?*.txt matches files starting with 'a' or 'b', then at least one character (due to '?'), then zero or more characters (due to '*'), ending with '.txt'. The matched files are: a1.txt, a2.txt, a10.txt, b1.txt, b2.txt. The file c1.txt does not match because it starts with 'c'. So total matched files are 5.