Jay Taylor's notes
back to listing indexBash wildcards: the square brackets [ ] and the curly brackets { } | LinuxG.net
[web search]Bash wildcards: the square brackets [ ] and the curly brackets { }
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 {}.
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
Related Posts
- How to set a new PATH in bash, ksh and zsh
- Bash wildcards: ? (question mark) and * (asterisk)
- The bash !$ trick: Insert the last argument of the previous command in the current command
- The bash wildcards: 10 practical examples of how to use them
- How to cd into a directory only by typing the directory name
Posted in The Linux and Unix Articles!
Leave a Reply
Your email address will not be published. Required fields are marked *
Comment
Name *
E-mail *
Website
- 5 Of The Most Popular Internet Browsers Available For Ubuntu
- How To Install Tor Browser Bundle 8.0.3 On Ubuntu 18.10 and Ubuntu 18.04 Via Repository
- How to Install Vivaldi 2.2 On Ubuntu 18.10 and Ubuntu 18.04 via Repository
- How to Install Opera 57.0. 3098.91 on Ubuntu 18.10 And Ubuntu 18.04 Via Repository
- How to Install HandBrake 1.2.0 on Ubuntu 18.10 and Ubuntu 18.04
- How to Install Brave Browser on Ubuntu 18.10 And Ubuntu 18.04
- How To Install Snap Packages and Use the Snap Package Manager Like A Ninja