Menu
Coddy logo textTech

The Star Wildcard

Part of the Fundamentals section of Coddy's Terminal journey — lesson 25 of 82.

A wildcard is a special character that acts as a placeholder to match one or more characters in filenames. Wildcards let you work with multiple files at once without typing every name.

The star wildcard * matches any number of characters (including zero). It is the most powerful and commonly used wildcard.

For example, to list all files ending in .txt:

ls *.txt

This matches any filename that ends with .txt, no matter how long the name is.

More examples:

Match all files starting with photo:

ls photo*

Match all files containing report anywhere in the name:

ls *report*

Match all files of any name or extension:

ls *

You can use * with any command, not just ls. For example, copy all .jpg files into a folder:

cp *.jpg photos/

Or delete all .log files at once:

rm *.log

Tip: Always run ls with your wildcard pattern first before using it with rm or mv — this way you can see exactly which files will be affected before making any changes.

challenge icon

Challenge

Beginner

Use the * wildcard to list only the .jpg files in the current directory.

Hint: Combine ls with the * wildcard and the .jpg extension to filter only image files.

Cheat sheet

A wildcard is a special character that matches one or more characters in filenames, allowing you to work with multiple files at once.

The star wildcard * matches any number of characters (including zero).

Examples:

List all files ending with .txt:

ls *.txt

List all files starting with photo:

ls photo*

List all files containing report anywhere in the name:

ls *report*

List all files:

ls *

Copy all .jpg files into a folder:

cp *.jpg photos/

Delete all .log files:

rm *.log

Tip: Always run ls with your wildcard pattern first before using it with rm or mv to see which files will be affected.

Try it yourself

Terminal
quiz iconTest yourself

This lesson includes a short quiz. Start the lesson to answer it and track your progress.

All lessons in Fundamentals