Unix making directory trees

no, i was using it as an example, as if it that tree were folders, how would the command look to make that tree.
 
I think that you need to browse to the directory where you want to create multiple folders. For example:
Code:
cd /folder1
And then create every folder seperately.
Code:
mkdir 01
mkdir 02
mkdir 03
 
I think that you need to browse to the directory where you want to create multiple folders. For example:
Code:
cd /folder1
And then create every folder seperately.
Code:
mkdir 01
mkdir 02
mkdir 03

Actually, Swansen actually had it better already:
Code:
mkdir -p work/homework/ch1/ch2
...that would make 'work', and the sub-dir 'ch1', and the sub-sub-dir 'ch2', all in one command.

To answer the question, the only thing I can think of would be a 'for' loop. In other words, simple scripting. But it'd be a pretty unusual situation when you'd need to do something like that, hence my relative ignorance... out of curiosity, what are you trying to do?
 
Just out of curiosity - do you issue the
Swansen said:
mkdir -p work/homework/ch1/ch2
after you already created
Swansen said:
mkdir work/homework
?

Or is the first command doing both actions in one go, i.e. creating the parent directory work/homwork and then two sub directories ch1 and 2?

If so, how does it know which is the parent directory? work, homework, ch1 or ch2?

Cheers! :cool:
 
you can build the whole tree in one command:

I know you could do

Code:
mkdir -p parent/{child1,child2}

but had a shot in the dark with the version below, which worked perfect

Code:
mkdir -p com/pisoftware/{people{/bmarshal,/jparker},group{/dev,/sysadmin}}
 
Specifically, i need to make the tree in the attachment. I did what donkey did only without the &&, so that was the missing link there. I found something similar to what Sniper is using there, but i was unsure of how to use the brackets. () I'm guessing they designate subfolders??
 

Attachments

  • cst126_lab08_filetree.png
    cst126_lab08_filetree.png
    4.6 KB · Views: 243
i havn't tested it but we were both thinking alike
Code:
cd ~/
mkdir -p /temp /professional/courses/major/cs381/labs /professional/courses/major/cs381/notes /professional/courses/major/cs381/programs /professional/courses/major/cs213 /professional/courses/major/cs475 /professional/courses/general /professional/societies/iee /professional/societies/acm /personal/funstuff /personal/taxes
should in theory create your dir structure
 
the curly brackets allow you to create multiple sub-folders in the target directory

say you wanted to create

parent -> child 1
parent -> child 2

easier but longer way

Code:
mkdir -p parent/child1 && parent/child2

instead you would do

Code:
mkdir -p parent/{child1,child2}


oh and your full tree, not as readable

Code:
mkdir -p YHD/{temp,personal{/funstuff,/taxes},professional{/courses{/general,/major{/cs213,/cs475,/cs381{/notes,/labs,/programs}}},/societies{/ieee,/acm}}}
 
Back
Top