Working with files in Linux can be time-consuming, especially when it comes to interacting with large amounts of data. This is where wildcards or placeholders come into play, helping you navigate and find files more efficiently and quickly. This guide shows you the different types of wildcards in Linux and explains how you can use them in the terminal.
Key Takeaways
- Wildcards are special symbols that stand for other characters and help refine search queries.
- The most common wildcard characters are the asterisk (*), the question mark (?), and square brackets ([]).
- You can combine wildcards to achieve more precise or broader search results.
Using Wildcards in Linux
Wildcards and Their Meanings
Wildcards are symbols used in the command line to select groups of files or specific files based on their names. A typical example in the terminal is the asterisk (*), which stands for zero or more characters.

Display All Files Starting with a Specific Letter
Assuming you want to list all files that start with the letter "S". You can do this with the following command:
This command will show you all files that start with the letter "S", followed by any characters.

Filter Files with Specific Extensions
If you want to list all files that end with "A2", you can do it like this:
This command will show you all files that end with "A2", regardless of whether they have an extension like.txt or.pdf.

Specify Strings with Placeholders
Sometimes you need a more specific search query. Suppose you want only the files that start with "SO". The command for that is:
Here, "SO" is combined with any further characters to return a filtered list of files.
Using the Question Mark for Wildcard Searches
The question mark (?) stands for exactly one character. If you are looking for a file like "TO", you can also enter:
This command will find "TO" as well as "TA", "TB", etc., because the question mark stands for any single character.

Ambiguous Strings
If you are looking for a file whose name consists of three characters, with two of them unknown, you can use the question mark for the unknown characters:
This will find files like "P1A3", "P2A3", and so on.

Using Square Brackets
With square brackets, you can specify ranges or specific characters. For example, to show only the files that contain "E", "N", or "O" in the middle, you can use the following command:
This searches explicitly for files that start with "S" and have either "E" or "N" as the second letter.
Combining Wildcards
The combination of different wildcards can help you search even more precisely. For example, to display all files that contain a number between 1 and 3, the command looks like this:
Here, the asterisk is used as a placeholder for any characters, while the brackets specify the number between 1 and 3.

Filter Specific Characters at the Beginning or End
If you want the listing of files to show only those that start with a number between 0 and 9, you can implement it like this:
This will show you all files that start with a number.

Summary – How Wildcards Work in Linux
Understanding and implementing wildcards in Linux is essential for efficiently navigating a file structure. Whether you are looking for specific files or wishing to filter groups, placeholders allow you to work effectively with the terminal. Knowledge of the various wildcards and their combinations will significantly increase your productivity.
Frequently Asked Questions
How do wildcards work in Linux?Wildcards are symbols used in the command line to select specific groups of files based on their names.
What is the difference between and?in wildcards? The asterisk () stands for zero or more characters, while the question mark (?) stands for exactly one character.
Can I combine wildcards?Yes, wildcards can be combined to create more accurate or broader search queries.
How do I use square brackets in wildcards?Square brackets allow you to specify specific characters or ranges of characters in a search query.
Are wildcards only applicable to files?No, wildcards can also be used in commands to access directories or other terminal commands.