Score:0

[] wildcard doesn't work

gb flag

I was watching a training video for learning Linux wildcards and I learnt some of them like {},*,?,[] etc. After that I wanted to make some practice and tried to create 300 directory in a folder which their names goes like folder 1,folder 2,folder 3 ..., then I tried to create 100 file which their names goes like file1.txt,file2.txt,file3.txt ... And then I wrote these commands to the terminal:

https://i.stack.imgur.com/7kOMn.png

I realized that I couldn't create what I want so I tried another wildcard which is "{}" and after that I wrote these commands to the terminal:

https://i.stack.imgur.com/E576w.png

As you can see, at the end of the process I was successful but I still don't know why "[]" wildcard didn't work. In the video I watched, the man was wrote the commands like the first picture I left and after that the folders were be created. Can someone explain me why that wildcard didn't work ?

cn flag
Ray
Just because someone made a video and placed it on-line doesn't mean that it is correct. For starters, perhaps he didn't use the bash shell?
pLumo avatar
in flag
Unfortunately, even [tldp.org](https://tldp.org/LDP/GNU-Linux-Tools-Summary/html/x11655.htm) says, that `{}` would be a wildcard. But that is not true, it's a very different mechanism although it can be used similarly, at least to select existing names.
Score:9
in flag

It is because you don't want to use a wildcard. A wildcard is to select existing names. (See Filename Expansion)

  • ? is a wildcard for any character, exactly once.
  • * is a wildcard for any character, any number of times.
  • [] is a character class wildcard, matching a class (a collection of one or more characters), once. Inside the brackets you set the allowed characters to match. [1-300] won't work.

{...} is what you want, but it is not a wildcard, it is called brace expansion.

Unfortunately, some tutorials are wrong about it.

TarikTEM avatar
gb flag
Oh, everything gained meaning in my mind right now thanks for your reply <3
mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.