Why I can't do something like this? mkdir folder/subfolder/
in order to achive this I have to do:
mkdir folder cd folder mkdir subfolder
Is there a better way to do it?
Creation of an entire directory tree can be accomplished with the mkdir command, which (as its name suggests) is used to make directories. The -p option tells mkdir to create not only a subdirectory but also any of its parent directories that do not already exist.
You can create directories one by one with mkdir, but this can be time-consuming. To avoid that, you can run a single mkdir command to create multiple directories at once. To do so, use the curly brackets {} with mkdir and state the directory names, separated by a comma.
If you want to create a directory containing several subdirectories, or a directory tree, using the command line in Linux, generally you have to use the mkdir command several times.
The first step in creating a new directory is to navigate to the directory that you would like to be the parent directory to this new directory using cd . Then, use the command mkdir followed by the name you would like to give the new directory (e.g. mkdir directory-name ).
You can:
mkdir -p folder/subfolder
The -p
flag causes any parent directories to be created if necessary.
To create multiple sub-folders
mkdir -p parentfolder/{subfolder1,subfolder2,subfolder3}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With