Sponsored Content
Top Forums Shell Programming and Scripting creating multiple sub-/directories using a shell script Post 302563349 by frymor on Tuesday 11th of October 2011 04:03:49 AM
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
 

10 More Discussions You Might Find Interesting

1. 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

2. 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

3. 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

4. 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

5. 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

6. 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

7. 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

8. 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

9. 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

10. 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
DROP 
USER(7) SQL Commands DROP USER(7) NAME
DROP USER - remove a database user account SYNOPSIS
DROP USER name DESCRIPTION
DROP USER removes the specified user from the database. It does not remove tables, views, or other objects owned by the user. If the user owns any database, an error is raised. PARAMETERS name The name of an existing user. DIAGNOSTICS
DROP USER The message returned if the user is successfully deleted. ERROR: DROP USER: user "name" does not exist This message occurs if the user name is not found. DROP USER: user "name" owns database "name", cannot be removed You must drop the database first or change its ownership. NOTES
Use CREATE USER [create_user(7)] to add new users, and ALTER USER [alter_user(7)] to change a user's attributes. PostgreSQL includes a program dropuser [dropuser(1)] that has the same functionality as this command (in fact, it calls this command) but can be run from the command shell. EXAMPLES
To drop a user account: DROP USER jonathan; COMPATIBILITY
The DROP USER statement is a PostgreSQL extension. The SQL standard leaves the definition of users to the implementation. SEE ALSO
CREATE USER [create_user(7)], ALTER USER [alter_user(l)], dropuser(1) SQL - Language Statements 2002-11-22 DROP USER(7)
All times are GMT -4. The time now is 04:14 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy