creating multiple sub-/directories using a shell script


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting creating multiple sub-/directories using a shell script
# 1  
Old 10-11-2011
Network creating multiple sub-/directories using a shell script

0
Hi,
I am looking for a way of creating multiple directories using the mkdir -p command in a shell script.
I'm working with an Ubuntu machine and try to do something like that:
#!/bin/sh

# Create required directories to support pipelines (BWAse, BWApe, and others to come...)

Code:
echo ***Creating  Directory Structure***
mkdir -p "temp/{temp1,temp2, temp3}"
mkdir -p temp/down/{struc1,struc2,struc3,struc4}

I would like to have each of the directories in the {} as sub-directories of the directory before.
The problem is that I get only one directory with the complete name inclusive the {}.
It looks like that:

Code:
ll -R temp
temp:
total 16
drwxr-xr-x  4  USER 4096 2011-10-11 09:53 ./
drwxr-xr-x 31  USER 4096 2011-10-11 09:53 ../
drwxr-xr-x  3  USER 4096 2011-10-11 09:53 down/
drwxr-xr-x  2  USER 4096 2011-10-11 09:53 {temp1,temp2, temp3}/

temp/down:
total 12
drwxr-xr-x 3  USER 4096 2011-10-11 09:53 ./
drwxr-xr-x 4  USER 4096 2011-10-11 09:53 ../
drwxr-xr-x 2  USER 4096 2011-10-11 09:53 {struc1,struc2,struc3,struc4}/

temp/down/{struc1,struc2,struc3,struc4}:
total 8
drwxr-xr-x 2  USER 4096 2011-10-11 09:53 ./
drwxr-xr-x 3  USER 4096 2011-10-11 09:53 ../

temp/{temp1,temp2, temp3}:
total 8
drwxr-xr-x 2  USER 4096 2011-10-11 09:53 ./
drwxr-xr-x 4 USER  4096 2011-10-11 09:53 ../

What am doing wrong? Is there a way of automating this procedure?
Thanks
Assa
# 2  
Old 10-11-2011
What gives the following command :
Code:
echo $0

?

What OS are you running ?
# 3  
Old 10-11-2011
Code:
mkdir -p "temp/{temp1,temp2, temp3}"

why dou you use with double quotes and a space before temp3..
remove this and try again.
Code:
mkdir -p temp/{temp1,temp2,temp3}

# 4  
Old 10-11-2011
if ur OS, not supportable with flower brackets .. try in this way ..
Code:
$ for i in temp1 temp2 temp3; do mkdir -p temp/$i; done

Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Creating script with multiple job arrays

Hello everyone, First of all this is my first post and im fairly new to working with Unix and creating scripts etc. so there will probably be wrong phrases used. Lets get to my questions. I have multiple scripts that submit Slurms/Jobs to the cluster starting like this and doing certain... (3 Replies)
Discussion started by: idbemad
3 Replies

2. Shell Programming and Scripting

Shell script to check current date file is created and with >0 kb or not for multiple directories

Hi All, I am new in scripting and working in a project where we have RSyslog servers over CentOS v7 and more than 200 network devices are sending logs to each RSyslog servers. For each network devices individual folders create on the name of the each network devices IP addresses.The main... (7 Replies)
Discussion started by: Pinaki
7 Replies

3. Shell Programming and Scripting

Need BASH Script Help to Move Files While Creating Directories

I've got this script to loop through all folders and move files that are more than 2 years old. I'm using the install command because it creates the necessary directories on the destination path and then I remove the source. I'd like to change the script to use the mv command since it is much... (4 Replies)
Discussion started by: consultant
4 Replies

4. Shell Programming and Scripting

Shell script for creating multiple users with password

for UserName in `cat users` ; do useradd -d /u02 -s /usr/libexec/openssh/sftp-server -G ftp-users $UserName ; PassWord=$( echo $( tr '' '' <<< ${UserName:0:1} )${UserName:1} ) ; echo "$PassWord@123" | passwd $UserName --stdin ; done can some one explain what the bold text do Please use... (5 Replies)
Discussion started by: James0806
5 Replies

5. Shell Programming and Scripting

Archiving and moving files into directories, creating directories, etc.

how can i move "dataName".sql.gz into a folder called 'database' and then move "$fileName".tar.gz * .htaccess into a folder called 'www' with the entire gzipped file being "$fileName".tar.gz? Is this doable or overly complex. so mydemo--2015-03-23-1500.tar.gz > database -... (5 Replies)
Discussion started by: wyclef
5 Replies

6. Shell Programming and Scripting

Single script to create multiple directories

Hi , I want a script to create a directories at different locations. suppose i am on home/path/zone1. I want to create a directory of current month in this location. Then i want to create the same current month directory in home/path/zone2.like this for 9 diffrent zones. I can do this... (4 Replies)
Discussion started by: sv0081493
4 Replies

7. UNIX for Dummies Questions & Answers

Deleting multiple directories inside multiple directories

Hi, Very unfamiliar with unix/linux stuff. Our admin is on vacation so, need help very quickly. I have directories (eg 40001, 40002, etc) that each have one subdirectory (01). Each subdir 01 has multiple subdirs (001, 002, 003, etc). They are same in each dir. I need to keep the top and... (7 Replies)
Discussion started by: kkouraus1
7 Replies

8. Shell Programming and Scripting

Find and execute shell scripts in multiple sub directories in parallel

I have one parent directory and within that parent directory there are several other sub-directories and within those sub-directories there are several other "large number" of sub-directories. All the sub directories have a shell script in them with a common file name execute_command.sh I want... (4 Replies)
Discussion started by: shoaibjameel123
4 Replies

9. Shell Programming and Scripting

bash script to rename multiple directories

Hello I have a directory structure with year in format 4 digits, e.g 2009, below which is month format 1 or 2 digits, e.g 1 or 12, blow which is day format 1 or 2 digits, e.g 1 or 31. I want to change the names of lots of directories to the be Year - 4 digits , e.g 2009 - No change here... (4 Replies)
Discussion started by: garethsays
4 Replies

10. Shell Programming and Scripting

help needed with creating challenging bash script with creating directories

Hi, Can someone help me with creating a bash shell script. I need to create a script that gets a positive number n as an argument. The script must create n directories in the current directory with names like map_1, map_2 etcetera. Each directory must be contained within its predecessor. So... (7 Replies)
Discussion started by: I-1
7 Replies
Login or Register to Ask a Question