mkdir: create multiple directories in one command

Written by
Date: 2012-12-27 18:00:32 00:00

When creating directories / folders under Linux, you will use mkdir command. If you want to create multiple directories in one shot, you can use this form of the command:

 mkdir -p /var/www/site/{public_html,logs}

That is going to create this structure:




The -p switch tells mkdir that if for example the folder site does not exist, it should be created too.

If you want, you can nest the curly brackets and create complex structures like this one:

 mkdir -p /home/user/mysite/{public_html/{css,js,images},logs}

That will create a folder structure like this one:


Learn to use it, and it will save you time.