James James - 11 months ago 62
Linux Question

Creating a full directory tree at once

I'm like a create a complex directory structure in a bash script and was under the impression the the following would work:

mkdir -p tmpdir/{trunk/sources/{includes,docs},branches,tags}

Which would create:

| | |
branches tags trunk
| |
includes docs

However when I run my script I end up with:


Is there a quick and easy way to do this or am I going to have to resort to

mkdir -p tmpdir/trunk/sources/includes
mkdir -p tmpdir/trunk/sources/docs
mkdir -p tmpdir/branches
mkdir -p tmpdir/tags

Answer Source

Change shebang to


to run the script with bash as it supports brace expansion.

The problem is that you are using shell that does not support it. Your /bin/sh does not point to /bin/bash but to something like /bin/dash.