What is a wildcard, and how can I use it?
Note: The Knowledge Base search does not permit wildcards.
A wildcard is a symbol that takes the place of an unknown character or set of characters. Commonly used wildcards are the asterisk ( * ) and the question mark ( ? ). Depending on the software or the search engine you are using, other wildcard characters may be defined.
When you are searching for files in Unix, DOS, or Windows, or on the web, you can simplify your search by using a wildcard. Wildcards may also simplify commands issued from the command line in Unix or DOS.
The asterisk ( * )
The asterisk represents any number of unknown characters. Use it when searching for documents or files for which you have only partial names.
For example, if you enter cheese* as your search term,
the search might return these items:
cheese
cheesecake
cheesedip.txt
If you enter *cheese as your search term, the search
might return these items:
stringcheese
swisscheese
sliced.cheese
For Unix or DOS, you can use the wildcard search in the command line
to list all the files with a particular extension. For example, if you
want to find all the files that end with .old, in DOS you
could enter your search as follows:
dir *.old
Or, in Unix, you could enter:
ls *.old
For most web search engines, wildcards increase the number of your
search results. For example, if you enter running as the
search term, the search will only return documents with that one
word. If you search using run* , the search results
may contain run, runner, and
running.
The question mark ( ? )
The question mark represents only one unknown character. Use it when you have a list of files with very similar names, or when you are unsure of a few characters.
For example, if you enter take?.txt as your search term,
the search might return these files:
take1.txt
taken.txt
take2.txt
However, it would not find take12.txt because the
question mark only covers one character. To find two unknown
characters, enter take??.txt as your search term.
Combining * and ?
You can use the asterisk ( * ) and the question mark
( ? ) anywhere in a search, and you can also use them
together. For example, if you want to find all the files that start
with home, followed by one or two characters, and ending
with any extension, enter home??.* as your search
term. Your search might return home45.bak or
homer4.txt, but not homeloan.doc.
Also see:
- In Windows, how do I locate a file if I know its name or its contents?
- In Unix, what is the find command, and how do I use it to search through directories for files?
- Introduction to Unix commands
- Online search basics
- For Mac OS and Mac OS X, what is Sherlock and how do I use it?
- In Unix, how do I use filename completion?
Last modified on November 06, 2006.






