One Linux Command to Create Multiple Subdirectories

To create multiple subdirectories with one Linux command, you can use the "mkdir" command with the "-p" option followed by the directory paths you want to create. For example, to create three subdirectories named "dir1", "dir2", and "dir3" within a directory called "parent", you can use the following command:


mkdir -p Lalatendu/{Partha/{Chintu,Swain},Pravash/{Sahoo1,Sahoo2},Sami/{Sahoo1,Sahoo2}}

You Can use the tree Command to View the folder and Sub folder structure

tree Lalatendu/

This will create all three subdirectories within the "parent" directory. The "-p" option ensures that the parent directory is also created if it does not exist. You can modify the command to include any number of subdirectories and directory paths.


The "-p" option in the "mkdir" command stands for "parents". It allows you to create a directory and any missing parent directories in the directory path.


For example, if you want to create a directory called "my_directory" within the "Documents" directory, but the "Documents" directory does not exist, you can use the "mkdir" command with the "-p" option as follows:

mkdir -p Documents/my_directory


This command will create the "Documents" directory if it does not exist and then create the "my_directory" directory within it.

Without the "-p" option, the "mkdir" command will only create the specified directory if its parent directories already exist. If a parent directory is missing, the command will fail and give an error message.

Read More :

How to create multiple files with random content  and size in linux ?  Example 1  & Example 2