mkdir command
I read the man page, but I wanted to know the proper syntax for making multiple directories and some with sub directories.
ie, a calendar setup Calendar >2002 >2003 >2004 ->Jan ->Feb ->Mar ->Apr ->May ->June ->Jul etc. Thanks in advance. |
You just use:
mkdir -p Calander/2004/Jan Calander/2004/Feb Calander/2004/Mar and so on... |
I saw online somewhere that there was something like this:
mkdir -p calendar{2000 2001 2002 2003} But I cant find it. It might have been with [] or maybe {}. Do you know about this at all? Thanks |
And here's a neat little shell expansion trick (although it is kinda ugly):
mkdir -p Calendar/200{2,3,4}/{Jan,Feb,Mar,Apr,May,Jun,Jul,Aug,Sep,Oct,Nov,Dec} |
That is what I was looking for!
Thanks both of you! |
Hehehe... responded while I was typing. What happens using the curly braces is that the shell expands the text so there will be one item for each value separated by a comma. So, with your example (replacing the spaces with commas and adding a forward slash):
mkdir -p calendar/{2000,2001,2002,2003} The shell expands that to: mkdir -p calendar/2000 calendar/2001 calendar/2002 calendar/2003 By repeating the curly braces, you "double up" so to speak. mkdir -p calendar/{2000,2001}/{Jan,Feb,Mar} becomes: mkdir -p calendar/2000/Jan calendar/2000/Feb calendar/2000/Mar calendar/2001/Jan calendar/2001/Feb calendar/2001/Mar |
All times are GMT -5. The time now is 05:23 PM. |