Linux - General This Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place. |
| Notices |
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
Are you new to LinuxQuestions.org? Visit the following links:
Site Howto |
Site FAQ |
Sitemap |
Register Now
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
 |
GNU/Linux Basic Guide
This 255-page guide will provide you with the keys to understand the philosophy of free software, teach you how to use and handle it, and give you the tools required to move easily in the world of GNU/Linux. Many users and administrators will be taking their first steps with this GNU/Linux Basic guide and it will show you how to approach and solve the problems you encounter.
Click Here to receive this Complete Guide absolutely free. |
|
 |
08-12-2004, 12:44 PM
|
#1
|
|
Member
Registered: Nov 2003
Location: Los Angeles, CA USA
Distribution: Mandrake 10.0
Posts: 86
Rep:
|
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.
|
|
|
|
08-12-2004, 12:48 PM
|
#2
|
|
Moderator
Registered: Mar 2003
Location: Scotland
Distribution: Slackware, RedHat, Debian
Posts: 12,047
Rep:
|
You just use:
mkdir -p Calander/2004/Jan Calander/2004/Feb Calander/2004/Mar
and so on...
|
|
|
|
08-12-2004, 12:57 PM
|
#3
|
|
Member
Registered: Nov 2003
Location: Los Angeles, CA USA
Distribution: Mandrake 10.0
Posts: 86
Original Poster
Rep:
|
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
|
|
|
|
08-12-2004, 12:59 PM
|
#4
|
|
Senior Member
Registered: Jan 2003
Posts: 2,786
|
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}
|
|
|
|
08-12-2004, 01:00 PM
|
#5
|
|
Member
Registered: Nov 2003
Location: Los Angeles, CA USA
Distribution: Mandrake 10.0
Posts: 86
Original Poster
Rep:
|
That is what I was looking for!
Thanks both of you!
|
|
|
|
08-12-2004, 01:03 PM
|
#6
|
|
Senior Member
Registered: Jan 2003
Posts: 2,786
|
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
|
|
|
|
| Thread Tools |
Search this Thread |
|
|
|
Posting Rules
|
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is Off
|
|
|
All times are GMT -5. The time now is 04:01 AM.
|
|
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.
|
Latest Threads
LQ News
|
|