How to create (make) multiple directories at one time using Unix/Linux

By Alvin J. Alexander, devdaily.com

Question: I'm about to go to work on a new server, and I want to create subdirectories named docs, bin, and lib, and the docs directory has two subdirectories named personal and business. How can I create these directories and subdirectories with one command?

Answer: It's simple. Use the "-p" option of the Unix/Linux mkdir command. The answer is shown below:

mkdir -p bin docs/personal docs/business lib

The "-p" option of the mkdir command tells mkdir to "create parent directories as needed" when it's told to create directories that are multiple levels deep, such as "docs/personal".


devdaily logo