Creating Directories with Wildcards
In Linux, you can use wildcards to create multiple directories at once. Wildcards are special characters that represent one or more characters in a filename or directory name.
Common Wildcards
The most commonly used wildcards in Linux are:
*
: Matches any number of characters
?
: Matches a single character
[]
: Matches any one of the characters enclosed within the brackets
Creating Directories with Wildcards
To create multiple directories using wildcards, you can use the mkdir
command with the -p
option to create the directories and any necessary parent directories.
Example:
## Create directories "dir1", "dir2", and "dir3"
mkdir dir{1,2,3}
## Create directories "file1", "file2", and "file3"
mkdir file{1..3}
## Create directories "abc1", "abc2", "abc3", "xyz1", "xyz2", and "xyz3"
mkdir {abc,xyz}{1..3}
You can also use wildcards to create directories with a specific pattern:
## Create directories "project_01", "project_02", "project_03", etc.
mkdir project_{01..10}
## Create directories "report_a", "report_b", "report_c", etc.
mkdir report_{a..e}
By using wildcards, you can save time and effort when creating a large number of directories with a similar structure.