In the previous wildcard post, I taught you how to use the asterisk * and the question mark ? wildcards. This article is about other, not so popular wildcards: the square brackets [ ] and the curly brackets {}.
![LINUXG 7StreamsNow - Bash wildcards: the square brackets [ ] and the curly brackets { } - LinuxG.net Watch Free Movies](https://linuxg.net/wp-content/uploads/2023/07/LINUXG-7StreamsNow.webp)
Note: These article is about the bash wildcards. The wildcards depend on the shell, not on the Operating System, so not all the bash wildcards work for other shells.
The bash square brackets [ ] wildcards:
The shell matches one character from the letters or digits inside the curly brackets: [123456], [abcde] or [1-6] [a-e] . If there is the ! character present inside the square brackets [ ], the shell will choose one character/digit not listed in the brackets: [!a-h], [!123].
$ ls
file1 file2 file3 file4 file5 file6
$ ls file[1-3]
file1 file2 file3
$ ls file[!146]
file2 file3 file5
The bash curly brackets { } wildcard:
The shell matches one word inside the curly brackets: {linux,unix} .
$ ls
file_BSD file_linux file_unix
$ ls file_{unix,linux}
file_linux file_unix