ARCHIVED: What is a wildcard, and how can I use it?

This content has been archived, and is no longer maintained by Indiana University. Information here may no longer be accurate, and links may no longer be available or reliable.

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 return only 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.

This is document ahsf in the Knowledge Base.
Last modified on 2018-01-18 12:44:22.