Wildcards are used in Linux to match filenames or patterns in commands. Here are some common wildcards and how to use them:
-
*(Asterisk): Matches zero or more characters.- Example:
ls *.txtlists all files with a.txtextension.
- Example:
-
?(Question Mark): Matches exactly one character.- Example:
ls file?.txtmatchesfile1.txt,fileA.txt, but notfile.txt.
- Example:
-
[abc]: Matches any one character specified within the brackets.- Example:
ls file[abc].txtmatchesfilea.txt,fileb.txt, andfilec.txt.
- Example:
-
[a-z]: Matches any one character in the specified range.- Example:
ls file[0-9].txtmatchesfile1.txt,file2.txt, etc.
- Example:
-
{}(Braces): Matches any of the comma-separated patterns within the braces.- Example:
ls file{1,2,3}.txtmatchesfile1.txt,file2.txt, andfile3.txt.
- Example:
You can use these wildcards in various commands like ls, cp, mv, and rm to perform operations on multiple files that match the specified patterns.
