Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

As man mkdir states

   -p, --parents
          no error if existing, make parent directories as needed

When I ran this command

mkdir -p work/{F1,F2,F3}/{temp1,temp2}

It creates a folder structure like this work parent folder then F1,F2,F3 child folders and temp1 and temp2 child folders under three parent folder F1,F2,F3.

     -F1 -temp1 -temp2
     -F2 -temp1 -temp2
     -F3 -temp1 -temp2

Now the problem is that I want to create temp1,temp2 folders only under F1 not under F2 and F3, but I'm confused on how I can write a command to do what I want.

share|improve this question
@Caleb: sorry, I was not aware we were both editing at the same time, it seems that revision merging is not implemented by SE :-/ – Stéphane Gimenez Aug 2 '11 at 13:48
@Stephane: No worries. I've made a lot of edits and it's pretty rare that two major edits get clobbered like that. Thanks for contributing! – Caleb Aug 2 '11 at 13:52
up vote 17 down vote accepted

Maybe this is what you are looking for?

 mkdir -p work/{F1/{temp1,temp2},F2,F3}
share|improve this answer
Hey, I was wondering recently if things could be done as simple as that. Thanks! – rozcietrzewiacz Aug 2 '11 at 13:55

A very good description of brace expansion (with examples) can be found at subsection Brace Expansion of bash manual (man bash, press / to start search and search for Brace Expansion).

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.