Creating directories within a directory?

Use and complete the template provided. The entire template must be completed. If you don't, your post may be deleted!

  1. The problem statement, all variables and given/known data:
    Ok i need to create a directory within another directory in one command. I'm already in a directory to. I need to create "Test" then create another two directories(test1 & test2) within "Test",
    School (Presentworkingdirectory)
    Test (1st directory)
    -test 1(2nd directory)
    -test 2(3rd directory)

  2. Relevant commands, code, scripts, algorithms:
    mkdir, mkdir-p and much more

  3. The attempts at a solution (include all code and scripts):
    I can only get it to make the directories in the same level.

  4. Complete Name of School (University), City (State), Country, Name of Professor, and Course Number (Link to Course):
    York University, Toronto, Canada, Mr. Grant, UNIX502

Note: Without school/professor/course information, you will be banned if you post here! You must complete the entire template (not just parts of it).

mkdir -p test/test1/test2

1 Like

also another question bro

are these relative pathnames right? or can they be made into them?

mkdir -p test1/test2/test3 (creating 3 consecutive directories)
mkdir -p ../back1 ../back2 (creating two seperate directories)
mkdir -p /test1/test2 test3 (working from the school directory)
^ the one i got help with from above

A relative path is one that is "rooted" in the current directory (no leading slant). A path name with a leading slash is an absolute path.

That should be enough information for you to answer your question.

oh yea i fixed my problems, but now im having trouble creating two directories in the same

test (directory1)
test1 (directory2)
test2 (directory3)

directory 2 and 3 are in directory 1

i tried mkdir -p test/test1/test2, but test3 is not going into directory 1 with directory 2

From man pages:

To be able in ONE command, mkdir that is you will have no other choice but to give the 2 directories in argument and using -p option:

mkdir -p test/test1 test/test2

which will create you:
/test # the directory
/test/test1 # the 2 subdirectories...
/test/test2
demo:

ezra:/tmp/vbe $ mkdir -p test/test1 test/test2; ll -ld test/*
drwxrwxr-x   2 vbe        bin             96 Oct 13 17:05 test/test1
drwxrwxr-x   2 vbe        bin             96 Oct 13 17:05 test/test2
ezra:/tmp/vbe $ ll
total 0
drwxrwxr-x   4 vbe        bin             96 Oct 13 17:05 test

Good exercice: Read the man pages...
start by typing man man

1 Like

Google is cool, too, and man pages on the browser.