Creating multiple directories in bash

The BASH ‘brace expansion‘ feature can be used to create whole directory trees using a single command.

$ mkdir -p root/{1/{1.1,1.2,1.3},2,3/{3.1,3.2/{3.2.1,3.2.2}}}

$ tree
.
`-- root
    |-- 1
    |   |-- 1.1
    |   |-- 1.2
    |   `-- 1.3
    |-- 2
    `-- 3
        |-- 3.1
        `-- 3.2
            |-- 3.2.1
            `-- 3.2.2

g33kadmin

I am a g33k, Linux blogger, developer, student and Tech Writer for Liquidweb.com/kb. My passion for all things tech drives my hunt for all the coolz. I often need a vacation after I get back from vacation....

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.