This article will walk you through some of the main wildcards available in Bash:

Match any string with *

The * wildcard will match any number of characters including no characters.

Expression Result
ls *.jpg lists all files ending with .jpg
ls pic* lists all files starting with pic
ls *abc* lists all files containing abc (including starting with and ending with abc)

Match a single character with ?

The ? wildcard will match a single character. That single character can be anything but can not be empty.

Expression Result
ls pic?.jpg lists all files like pic1.jpg, picA.jpg or picz.jpg. It will not match pic.jpg

Match a set of characters with [xyz]

Use [ ] to have one single character match a defined set of characters.
[123abc] means will match 1, 2, 3, a, b or c.

Expression Result
pic[123].jpg Will only match pic1.jpg, pic2.jpg and pic3.jpg

Match a range of characters with [a-z]

Use [-] to have one character be within certain range.

Expression Result
[a-e] Will match a, b, c, d or e
[a-z] Will match any lowercase letter
[0-9] Will match any digit
[A-Za-z] Will match any letter
[a-e1-5] Will match any lowercase letter between a and e or any digit between 1 and 5
[a-e123] Will match any lowercase letter between a and e or any digit equal to 1, 2 or 3
[0-10] Will match 0 or 1 (0 to 1 range or 0)

Invert a selection with ^

Use ^ to invert a selection

Expression Result
[^78] Will match any character (including letters) different than 7 and 8
[^a-z] Will match any character that is not a lowercase letter

Match several expressions with {abc,xyz}

Use {expr1,expr2} to match expr1 and expr2

Expression Result
ls {*.jpg,*.gif} Will list any file with the jpg or gif extension