Great question! The wildcard [a-z] follows the same logic as [abc], but it uses a hyphen (-) to represent a range of characters.
Instead of typing every single letter, [a-z] matches any single lowercase letter from 'a' to 'z'.
How it works:
- Matches: Any one lowercase character (a, b, c, ... x, y, z).
- Does NOT match: Numbers, uppercase letters (usually, depending on your system's settings), or special symbols.
Practical Examples:
If you have a folder with these files:
note_a.txtnote_b.txtnote_1.txt
The command ls note_[a-z].txt would only show note_a.txt and note_b.txt. It would ignore note_1.txt because 1 is not a letter.
Other common ranges:
[A-Z]: Matches any single uppercase letter.[0-9]: Matches any single digit from 0 to 9.- Try this in your current lab! Since you created
file1.txtthroughfile3.txt, you can run:ls file[0-9].txt
- Try this in your current lab! Since you created
You can even combine them! For example, [a-zA-Z] matches any letter regardless of case.
Happy experimenting, you're doing great with these wildcards