A Quick Introduction to Unix/Wildcards

From Wikibooks, open books for an open world
Jump to navigation Jump to search


A wildcard is a character that can stand for all members of some class of characters. When you use a wildcard the computer systems substitutes the members of the class for the wildcard character. The examples below will make this clearer. We will use the command ls for illustration.

The * wildcard[edit]

The character * is a wildcard and matches zero or more character(s) in a file (or directory) name. For example, in your mytraining directory, you might type

% ls list*

This will list all files in the current directory starting with list.

You could type

% ls *list

This will list all files in the current directory ending with list.

The ? wildcard[edit]

The character ? will match exactly one character.

So ?ouse will match files like house and mouse, but not grouse.

An example use of this syntax is:

% ls ?list