Is it possible to recursively create folders using a shell script?

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?


  • You should pass the -p parameter to mkdir so it will create all the subfolders. So following your example:

    mkdir -p folder1/folder2/folder3