Selecting Multiple Targets
Wildcards, or globbing, are special characters used to represent patterns in filenames or paths. They allow you to operate on multiple files with a single command.
The Asterisk (*)
The asterisk matches zero or more characters in a filename.
-
Match all files: bash $ ls *
Lists everything in the current directory
-
Match files with specific extension: bash $ cp *.txt backup/
Copies all files ending in .txt to backup/
-
Match files starting with a prefix: bash $ rm log_*.bak
Removes all files starting with 'log_' and ending in '.bak'
The Question Mark (?)
The question mark matches exactly one character.
bash $ ls file?.txt