LinuxQuestions.org
Review your favorite Linux distribution.
Home Forums Tutorials Articles Register
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 03-28-2010, 12:28 PM   #1
nic2
LQ Newbie
 
Registered: Aug 2004
Location: Johannesburg, South Africa
Distribution: ubuntu 10.4
Posts: 6

Rep: Reputation: 0
[Solved] Creating Multiple Directories


I need to create subdirectories in about 300 existing directories - the subdirectory will have the same name in all 300 existing directories.

How do I do this using the mkdir command using a regular expression or globbing?

Last edited by nic2; 03-29-2010 at 10:53 AM.
 
Old 03-28-2010, 01:57 PM   #2
kirukan
Senior Member
 
Registered: Jun 2008
Location: Eelam
Distribution: Redhat, Solaris, Suse
Posts: 1,278

Rep: Reputation: 148Reputation: 148
Try this
Quote:
#for n in *; mkdir -p $n/subdirectoryname; done
 
Old 03-28-2010, 02:25 PM   #3
bastl
Member
 
Registered: Sep 2003
Location: Germany/BW
Distribution: My own
Posts: 237

Rep: Reputation: 22
Write a shell script like:
Code:
#!/bin/bash
LIST=`ls -D`
for i in $LIST ;
do
	mkdir $i"/yourdir"
done
Change "yourdir" to the directory you want to be created in the subdirs
If you have also files in your directory you will get some errors that it is no directory.
 
1 members found this post helpful.
Old 03-29-2010, 10:51 AM   #4
nic2
LQ Newbie
 
Registered: Aug 2004
Location: Johannesburg, South Africa
Distribution: ubuntu 10.4
Posts: 6

Original Poster
Rep: Reputation: 0
@bastl Script work like a charm, thank you
 
  


Reply



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
Creating a script to move or copy files into multiple directories below the files matthes138 Linux - Newbie 5 08-25-2009 04:57 PM
Creating multiple directories atheist Linux - Newbie 6 02-20-2009 04:32 AM
Creating Multiple Directories in the same location in user space leebrent Linux - General 3 10-29-2007 12:14 PM
Change text in multiple files in multiple directories vivo2341 Linux - General 5 11-27-2006 08:16 PM
Searching multiple directories and sub directories for a file jeep99899 Linux - Newbie 2 10-13-2005 12:23 PM

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

All times are GMT -5. The time now is 08:16 PM.

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