Off topic:How To Create Multiple Directories Using A Shell Script?
2
0
Entering edit mode
12.5 years ago
Assa Yeroslaviz ★ 1.8k

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

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:

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

scripting • 11k views
ADD COMMENT
This thread is not open. No new answers may be added
Traffic: 2330 users visited in the last hour
Help About
FAQ
Access RSS
API
Stats

Use of this site constitutes acceptance of our User Agreement and Privacy Policy.

Powered by the version 2.3.6