0
0
Linux CLIscripting~5 mins

File globbing (wildcards *, ?, []) in Linux CLI - Cheat Sheet & Quick Revision

Choose your learning style9 modes available
Recall & Review
beginner
What does the wildcard * mean in file globbing?
The * wildcard matches zero or more characters in file names. For example, *.txt matches all files ending with .txt.
Click to reveal answer
beginner
How does the ? wildcard work in file globbing?
The ? wildcard matches exactly one character. For example, file?.txt matches file1.txt or fileA.txt but not file12.txt.
Click to reveal answer
beginner
What is the purpose of square brackets [] in file globbing?
Square brackets [] match any one character inside them. For example, file[123].txt matches file1.txt, file2.txt, or file3.txt.
Click to reveal answer
beginner
How would you match all files starting with 'data' and ending with '.csv' using globbing?
Use the pattern data*.csv. The * matches any characters between 'data' and '.csv'.
Click to reveal answer
intermediate
What does the pattern file[!a-c].txt match?
It matches files named file followed by any single character except 'a', 'b', or 'c', then .txt. For example, filed.txt matches but filea.txt does not.
Click to reveal answer
Which wildcard matches exactly one character?
A?
B{}
C[]
D*
What does the pattern *.sh match?
AAll files ending with .sh
BAll files starting with .sh
CFiles with exactly 3 characters
DFiles named * or .sh
How do you match files named file1.txt, file2.txt, or file3.txt but not file4.txt?
Afile?.txt
Bfile[123].txt
Cfile*.txt
Dfile[!123].txt
What does the pattern file[!a-c].txt do?
AMatches files starting with filea-c
BMatches files with a, b, or c after file
CMatches files without a, b, or c after file
DMatches files ending with a-c.txt
Which pattern matches all files starting with 'log' and ending with any single character?
Alog*
Blog[?]
Clog[]
Dlog?
Explain how the wildcards *, ?, and [] work in file globbing with examples.
Think about how you find files by patterns in a folder.
You got /4 concepts.
    Describe how to exclude certain characters using file globbing patterns.
    It's like saying 'match anything except these letters'.
    You got /3 concepts.