Last Updated: February 25, 2016
·
1.014K
· darkelda

Create multiple subfolders

mkdir -p parent/{folder1,folder2,folder3,folder4,folder5}

.
├── main
│   ├── folder1
│   ├── folder2
│   ├── folder3
│   ├── folder4
│   └── folder5

8 Responses
Add your response

What's the difference from
mkdir folder1 folder2 folder3 folder4 folder5
?

over 1 year ago ·

The difference is you can make multiple subfolders without write the base path.

Try mkdir -p parentFolder/childFolder/{folder1,folder2,folder3,folder4,folder5}

over 1 year ago ·

@nantunes I think its the same.
though like this usage is affective:
mkdir -p foo/{bar,baz}

over 1 year ago ·

Oh, great! :-)

over 1 year ago ·

@tacahiroy yes it's what I want to say with this "pro tip"

over 1 year ago ·

I have updated it to better illustrate the purpose of this "pro tips"

over 1 year ago ·

Not to forget that you can have folders after the set. mkdir -p foo/{bar,baz}/hello will create

foo/
   bar/
     hello/
   baz/
     hello/

Or you can have a partial name. mkdir hello{1..5}world will create hello1world, hello2world, hello3world, etc.

Manual entry: http://tldp.org/LDP/Bash-Beginners-Guide/html/sect_03_04.html

over 1 year ago ·

Thanks @shawncplus for the precision

over 1 year ago ·