Privacy Policy
© 2025 linux101.dev

Bash: Wildcards

Wildcards are special characters used to match patterns in file names and paths. They are a powerful tool for selecting multiple files at once.

Asterisk (`*`)

Matches any sequence of characters

ls *.txt

This command lists all files in the current directory that end with the `.txt` extension.

Matching multiple parts of a name

rm report_*.log

This command deletes all files that start with `report_` and end with `.log`.

Question Mark (`?`)

Matches any single character

ls file?.txt

This command lists files like `file1.txt`, `file2.txt`, and `fileA.txt`, but not `file10.txt`.

Brackets (`[]`)

Matches a single character from a set

ls [abc].txt

This command lists files named `a.txt`, `b.txt`, and `c.txt`.

Using a range

ls [0-9].txt

This command lists all files with a single digit in their name, from `0.txt` to `9.txt`.