Wildcards match names that exist. To make new files or directories, you need a way to write many names quickly. That is brace expansion.
One word for each item
Put items between { and }, with commas between them. The shell makes one word for each item, with the text around the braces:
mkdir archive/{jan,feb,mar}you type
mkdir archive/jan archive/feb archive/marmkdir runs with 3 arguments
text
learner@tidepool:~$ echo {mon,tue,wed}.txt
mon.txt tue.txt wed.txt
learner@tidepool:~$ touch days/{mon,tue,wed}.txtNo spaces go inside the braces. {mon, tue} is not brace expansion.
Make a backup copy quickly
An empty item gives the text around the braces with nothing added:
text
learner@tidepool:~/shop$ echo prices.txt{,.bak}
prices.txt prices.txt.bak
learner@tidepool:~/shop$ cp prices.txt{,.bak}Braces or wildcards?
Wildcards: * ? [ ] | Braces: {a,b} | |
|---|---|---|
| Look at | Names that exist | Only the text that you typed |
| Use for | Select files that exist | Make or name new things |
| When nothing matches | The pattern stays as it is | There is always a result |