[] wildcard doesn't work

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 ?


Solution 1:

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.