0

I just used mkdir myDir{1,2,3} to create 3 directories called myDir1, myDir2 and myDir3 in the same root directory. Now I'm trying to create 5 subdirectories in each by using

mkdir ~/myDir*/subDir{1,2,3,4,5}

but it's giving me a file already exists message. When I do an ls on the root directory or check in each of the myDir directories, nothing is in them. I've also tried the variation mkdir /myDir*/subDir{1,2,3,4,5} while in the root directory just in case with the same result.


Thanks.

2
Contributors
5
Replies
6
Views
8 Years
Discussion Span
Last Post by eggi
0

Hey there,

Just use the -p option to make dir and it should quit complaining about the directory already existing and do what you want. Also, if you don't need to make those dirs under multiple subdirs, you can remove the * character; that may cause it to give you a "no such file or directory" error.

Best wishes,

Mike

0

Thanks I got it working with

mkdir -p ~/myDir{1,2,3}/subDir{1,2,3,4,5}

now I'm trying to figure out the last step, making files called myFile1,2,3,4 go in each of the subDir's with just one touch command. I know the beg of it...


touch myFile{1,2,3,4,5}

0

You got it :)

Just add that to the end and you're set!

, Mike

$ touch x{1,2,3}/y{1,2,3,4,5}/myfile{1,2,3,4,5}

$ ls -R x{1,2,3}
x1:
y1 y2 y3 y4 y5

x1/y1:
myfile1 myfile2 myfile3 myfile4 myfile5

x1/y2:
myfile1 myfile2 myfile3 myfile4 myfile5

x1/y3:
myfile1 myfile2 myfile3 myfile4 myfile5

x1/y4:
myfile1 myfile2 myfile3 myfile4 myfile5

x1/y5:
myfile1 myfile2 myfile3 myfile4 myfile5

x2:
y1 y2 y3 y4 y5

x2/y1:
myfile1 myfile2 myfile3 myfile4 myfile5

x2/y2:
myfile1 myfile2 myfile3 myfile4 myfile5

x2/y3:
myfile1 myfile2 myfile3 myfile4 myfile5

x2/y4:
myfile1 myfile2 myfile3 myfile4 myfile5

x2/y5:
myfile1 myfile2 myfile3 myfile4 myfile5

x3:
y1 y2 y3 y4 y5

x3/y1:
myfile1 myfile2 myfile3 myfile4 myfile5

x3/y2:
myfile1 myfile2 myfile3 myfile4 myfile5

x3/y3:
myfile1 myfile2 myfile3 myfile4 myfile5

x3/y4:
myfile1 myfile2 myfile3 myfile4 myfile5

x3/y5:
myfile1 myfile2 myfile3 myfile4 myfile5

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.