Hi all,

I need to create thousands of directories in a single parent directory using shell scripting code. One problem would be to generate the unique directory name for each of the 1000 iterations to create a directory every time. ie first time the directory name needs to be subdir1 and then subdir2 for the next iteration and so on.
Could anyone please help me with the script?

Thanking you,

Recommended Answers

All 7 Replies

for i in `seq $ITERATIONS`; do mkdir /dir/subdir$i ; done

^Thanks. I also wanted to find how to that.

'seq' may not work in all environments.
Here is the code.

mkdir subdir_$j 2> /dev/null

to delete again:

rmdir subdir_$j  2> /dev/null

good point, I tend to be too Linux focused :)

Let me know in case of any problem with he script in any
environments like:

UBUNTU and all flavours.

Hi thanks DimaYasny and all,
the script (with the seq) did work for me..

Hey Prashanth, If you got your answer then please mark this thread as solved and close it.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.