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 *.txtThis command lists all files in the current directory that end with the `.txt` extension.
Matching multiple parts of a name
rm report_*.logThis command deletes all files that start with `report_` and end with `.log`.
Question Mark (`?`)
Matches any single character
ls file?.txtThis 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].txtThis command lists files named `a.txt`, `b.txt`, and `c.txt`.
Using a range
ls [0-9].txtThis command lists all files with a single digit in their name, from `0.txt` to `9.txt`.