1751811 Members
5411 Online
108781 Solutions
New Discussion юеВ

directories

 
SOLVED
Go to solution
rajesh73
Super Advisor

directories

Hi ALL

i want to create multiple directories in one particular directories(apporximately around 150 folders).

Regds
Rajesh
6 REPLIES 6
Bhadresh
Trusted Contributor
Solution

Re: directories

Hi Rajesh,

mkdir -p can be useful. Please have a look at mkdir man page:

http://docs.hp.com/en/B2355-90689/mkdir.1.html

Hope this helps.

Regards,
Bhadresh
Michal Kapalka (mikap)
Honored Contributor

Re: directories

hi,

for example :

mkdir /test/{1,2,3,4,5,6,7,8,9,10}{1,2,3,4,5,6,7,8,9,10}

mikap
Hein van den Heuvel
Honored Contributor

Re: directories

>> mkdir /test/{1,2,3,4,5,6,7,8,9,10}{1,2,3,4,5,6,7,8,9,10}

mikap,

A fine suggestion.
Thank you for reminding us of that.
You may have been too enthusiastic though.
Most probably do NOT want those 10's in there, but just zeroes.

For example: mkdir /test/{0..9}{0..9}

myself, I prefer a full prinf function to construct names as I like them.
For example using perl:

# perl -e 'for (1..150) { $x = sprintf "test_%03d", $_; mkdir $x }'

cheers,
Hein
Dennis Handly
Acclaimed Contributor

Re: directories

>mikap: mkdir /test/{1,2,3,4,5,6,7,8,9,10}{1,2,3,4,5,6,7,8,9,10}

I'm not aware of this syntax working in a real shell?
You would have to use a while with typeset for leading zeros. Or create a file with your unique pattern of directory names.
Raj D.
Honored Contributor

Re: directories

Rajesh,

Here it is:

- To create:
# perl -e 'while ($i++<150){system "mkdir test$i"}'



- To check:
# find . -type d -name "test*" | wc -l
150


Enjoy, Have fun!,
Raj.
" If u think u can , If u think u cannot , - You are always Right . "
Hein van den Heuvel
Honored Contributor

Re: directories

Raj D >> - To create: # perl -e 'while ($i++<150){system "mkdir test$i"}'

Hmm,
Why would use 'system' to launch a command, when a direct call is available, as I showed in my earlier alternative solution?

Using the 'system' step will be less efficient and has reduced error handling.

fwiw,
Hein