LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - General
User Name
Password
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


Reply
  Search this Thread
Old 09-19-2011, 04:12 AM   #1
Pedroski
Senior Member
 
Registered: Jan 2002
Location: Nanjing, China
Distribution: Ubuntu 20.04
Posts: 2,116

Rep: Reputation: 73
make directory


Hi! I want to make 18 directories, Week 1, Week 2, ....Week 18

I think that must be something I can do in a terminal rather than manually.

Something like:

for i=1 to 18

md Week i

But quite where I need apostrophies and or commas or brackets I have no idea. Can you give me a tip??
 
Old 09-19-2011, 04:14 AM   #2
langner
LQ Newbie
 
Registered: Aug 2010
Location: Netherlands
Distribution: Debian
Posts: 9

Rep: Reputation: 0
In bash:
Code:
for i in `seq 1 18`; do mkdir "Week $i"; done
 
Old 09-19-2011, 04:17 AM   #3
druuna
LQ Veteran
 
Registered: Sep 2003
Posts: 10,532
Blog Entries: 7

Rep: Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405
Hi,

Assuming there needs to be a space between Week and the following number:
Code:
mkdir "Week "{1..18}
The {1..18} part tells bash a range is given. This would also work, but is not as compact {1,2,3,4,5,6,7} (stopped at 7, too much typing )

Hope this helps.
 
1 members found this post helpful.
Old 09-19-2011, 05:24 AM   #4
Pedroski
Senior Member
 
Registered: Jan 2002
Location: Nanjing, China
Distribution: Ubuntu 20.04
Posts: 2,116

Original Poster
Rep: Reputation: 73
Thanks very much! I tried the last tip first, (less writing, I am lazy!) and it worked perfectly!

Clever stuff that bash!
 
Old 09-19-2011, 06:59 AM   #5
druuna
LQ Veteran
 
Registered: Sep 2003
Posts: 10,532
Blog Entries: 7

Rep: Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405
You're welcome
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
How to make a sub directory to one directory..? mlibot Linux - Newbie 7 08-26-2009 08:44 AM
Make a CD Directory Available For Execution gakusei Linux - Newbie 3 12-10-2008 01:51 PM
Can I Make make Believe Root Is a Different Directory? binarybob0001 Linux - General 5 11-20-2006 03:33 AM
make from an child directory. ashlesha Linux - General 2 07-19-2006 07:47 PM
allow user to make directory RajRed Linux - General 10 02-20-2006 09:51 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - General

All times are GMT -5. The time now is 08:18 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration