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
CREATE USER 
MAPPING(7) SQL Commands CREATE USER MAPPING(7) NAME
CREATE USER MAPPING - define a new mapping of a user to a foreign server SYNOPSIS
CREATE USER MAPPING FOR { username | USER | CURRENT_USER | PUBLIC } SERVER servername [ OPTIONS ( option 'value' [ , ... ] ) ] DESCRIPTION
CREATE USER MAPPING defines a mapping of a user to a foreign server. A user mapping typically encapsulates connection information that a foreign-data wrapper uses together with the information encapsulated be a foreign server to access an external data resource. The owner of a foreign server can create user mappings for that server for any user. Also, a user can create a user mapping for his own user name if USAGE privilege on the server has been granted to the user. PARAMETERS
username The name of an existing user that is mapped to foreign server. CURRENT_USER and USER match the name of the current user. When PUB- LIC is specified, a so-called public mapping is created that is used when no user-specific mapping is applicable. servername The name of an existing server for which the user mapping is to be created. OPTIONS ( option 'value' [, ... ] ) This clause specifies the options of the user mapping. The options typically define the actual user name and password of the map- ping. Option names must be unique. The allowed option names and values are specific to the server's foreign-data wrapper. EXAMPLES
Create a user mapping for user bob, server foo: CREATE USER MAPPING FOR bob SERVER foo OPTIONS (user 'bob', password 'secret'); COMPATIBILITY
CREATE USER MAPPING conforms to ISO/IEC 9075-9 (SQL/MED). SEE ALSO
ALTER USER MAPPING [alter_user_mapping(7)], DROP USER MAPPING [drop_user_mapping(7)], CREATE FOREIGN DATA WRAPPER [create_for- eign_data_wrapper(7)], CREATE SERVER [create_server(7)] SQL - Language Statements 2010-05-14 CREATE USER MAPPING(7)
All times are GMT -4. The time now is 01:36 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy