I'm trying to recursively create levels of directories like /folder1/folder2/folder3
I'm trying mkdir folder1/folder2/folder3
, but it doesn't work. How can I do it?
The -p option is used to create multiple child directories with mkdir command in a recursive manner. In order to create directories recursively non of the specified directories should exist because all of them are created automatically.
The procedure is as follows: Open the terminal application in Linux. The mkdir command is is used to create new directories or folders. Say you need to create a folder name dir1 in Linux, type: mkdir dir1.
Alternatively referred to as recursive, recurse is a term used to describe the procedure capable of being repeated. For example, when listing files in a Windows command prompt, you can use the dir /s command to recursively list all files in the current directory and any subdirectories.
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 should pass the -p
parameter to mkdir
so it will create all the subfolders. So following your example:
mkdir -p folder1/folder2/folder3
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