0
0
Linux CLIscripting~20 mins

File globbing (wildcards *, ?, []) in Linux CLI - Practice Problems & Coding Challenges

Choose your learning style9 modes available
Challenge - 5 Problems
🎖️
File Globbing Master
Get all challenges correct to earn this badge!
Test your skills under time pressure!
💻 Command Output
intermediate
1:30remaining
What files match this pattern?
Given a directory containing files:
report1.txt, report2.txt, report_final.txt, summary.txt, data.csv
What files will match the pattern report?.txt?
Areport1.txt, report2.txt, report_final.txt
Breport1.txt, report2.txt
Creport_final.txt
Dsummary.txt, data.csv
Attempts:
2 left
💡 Hint
The question mark matches exactly one character.
💻 Command Output
intermediate
1:30remaining
Which files match the pattern with brackets?
In a folder with files: data1.csv, data2.csv, data3.csv, dataA.csv, dataB.csv
Which files match the pattern data[12].csv?
Adata1.csv, data2.csv, data3.csv
Bdata3.csv
CdataA.csv, dataB.csv
Ddata1.csv, data2.csv
Attempts:
2 left
💡 Hint
Square brackets match exactly one character from the set inside.
📝 Syntax
advanced
2: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?
A*.{log,txt}
B*.[log|txt]
C*.[log,txt]
D*.(log|txt)
Attempts:
2 left
💡 Hint
Brace expansion is used to match multiple extensions.
💻 Command Output
advanced
1:30remaining
What is the output of this glob pattern?
Given files: file1.txt, file2.txt, file10.txt, file20.txt, fileA.txt
What files match the pattern file?.txt?
Afile1.txt, file2.txt, fileA.txt
Bfile1.txt, file2.txt
Cfile10.txt, file20.txt
DfileA.txt
Attempts:
2 left
💡 Hint
The question mark matches exactly one character.
🧠 Conceptual
expert
2:30remaining
How many files match this complex pattern?
In a directory with files: a1.txt, a2.txt, a10.txt, b1.txt, b2.txt, c1.txt
How many files match the pattern [ab]?*.txt?
A3
B4
C5
D6
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'.