The
question mark (?) is used to replace a single character in a string.
For example the command ls
d? would return any file that has two characters in the name
and start with the letter d. The command ls
??d would return any files that end with a d and have three
letters in the name. This metacharacter is also known as a wildcard
character.
Examples
The
following example will display all of the files that have a single
character following the string chuck:
$
ls
Franklin Pig_Pen Snoopy Woodstock blankets blankets_6 chuck
chuck_1 game genius marcy mud.puddles sally
$
ls chuck?
chuck1:
Cool_dog
blankets baseball
dog_house
feathers_6 bird
chuck2:
Flight
Hero
chuck3:
Dirt mud
$
If no file name matches the wildcard character, you will
receive the following message:
$
ls z?
z?: No such file or directory
$