1/6

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.txt

What the output means

  • notes.txt and todo.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. *.txt only matches names in one folder.
  • Typing a space: ls * .txt means everything, then a file called .txt.

Tap Run to list every .txt file in your home folder.

Try it:ls *.txt
learner@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