Files & folders · Wildcards
Match many files: *
A wildcard is a pattern that matches file names. * matches any run of characters (even none). So *.txt means every name that ends in .txt.
The shell replaces the pattern with the matching names before the command runs, so it works with any command: ls *.txt, cat *.txt, rm *.txt.
How to type it: ls *.txt, or with a folder: ls Downloads/*.txt.
Worked example
learner@shellstreak:~$ ls *.txt
notes.txt
todo.txtWhat the output means
notes.txtandtodo.txt: the two names in your home folder that end in.txt. Folders and other files didn't match.
Common mistakes
- Expecting
*to look inside folders.*.txtonly matches names in one folder. - Typing a space:
ls * .txtmeans everything, then a file called.txt.
Tap Run to list every .txt file in your home folder.
Try it:
ls *.txtlearner@shellstreak: ~
Starting your practice shell…
You can also type in the terminal yourself. Try anything: you can't break it.
Go deeper: Basic terminal commands for beginners