Creating directories within a directory?

 
Thread Tools Search this Thread
Homework and Emergencies Homework & Coursework Questions Creating directories within a directory?
# 1  
Old 10-12-2010
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).
# 2  
Old 10-12-2010
mkdir -p test/test1/test2
This User Gave Thanks to DGPickett For This Post:
# 3  
Old 10-12-2010
Quote:
Originally Posted by DGPickett
mkdir -p test/test1/test2
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
# 4  
Old 10-12-2010
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.
# 5  
Old 10-12-2010
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
# 6  
Old 10-13-2010
From man pages:
Quote:
mkdir(1) mkdir(1)

NAME
mkdir - make a directory

SYNOPSIS
mkdir [-p] [-m mode] dirname ...

DESCRIPTION
mkdir creates specified directories in mode 0777 (possibly altered by
umask unless specified otherwise by a -m mode option (see umask(1)).
Standard entries, . (for the directory itself) and .. (for its parent)
are created automatically. If dirname already exists, mkdir exits
with a diagnostic message, and the directory is not changed.

Options
mkdir recognizes the following command-line options:

-m mode After creating the directory as specified, the file
permissions are set to mode, which is a symbolic mode
string as defined for chmod (see chmod(1)). The
umask(1) has precedence over -m.

-p Intermediate directories are created as necessary.
Otherwise, the full path prefix of dirname must
already exist. mkdir requires write permission in
the parent directory.

For each directory name in the pathname prefix of the
dirname argument that is not the name of an existing
directory, the specified directory is created using
the current umask setting, except that the equivalent
of chmod u+wx is done on each component to ensure
that mkdir can create lower directories regardless of
the setting of umask. Each directory name in the
pathname prefix of the dirname argument that matches
an existing directory is ignored without error. If
an intermediate path component exists, but has
permissions set to prevent writing or searching,
mkdir fails with an error message.

If the -m option is used, the directory specified by
dirname (excluding directories in the pathname
prefix) is created with the permissions specified by
mode.
etc...
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:
Code:
mkdir -p test/test1 test/test2

which will create you:
/test # the directory
/test/test1 # the 2 subdirectories...
/test/test2
demo:
Code:
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
This User Gave Thanks to vbe For This Post:
# 7  
Old 10-13-2010
Google is cool, too, and man pages on the browser.
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Creating new directories

I want to create a new system of directory structure for example mkdir -p ./iv.sac/resu/hhz.d However, I think that `mkdir -p` overwrites the directories. I want to avoid that and am doing something as follows in my bash script echo -e "\nCreating directories:" ... (6 Replies)
Discussion started by: kristinu
6 Replies

2. Shell Programming and Scripting

Archiving and moving files into directories, creating directories, etc.

how can i move "dataName".sql.gz into a folder called 'database' and then move "$fileName".tar.gz * .htaccess into a folder called 'www' with the entire gzipped file being "$fileName".tar.gz? Is this doable or overly complex. so mydemo--2015-03-23-1500.tar.gz > database -... (5 Replies)
Discussion started by: wyclef
5 Replies

3. Shell Programming and Scripting

How to list all the files, directories and sub-directories in the current path except one directory?

Can anyone come up with a unix command that lists all the files, directories and sub-directories in the current directory except a folder called log.? Thank you in advance. (7 Replies)
Discussion started by: Manjunath B
7 Replies

4. Shell Programming and Scripting

need help with creating directories and variables

i'm trying to write a script that has 2 variables, and uses the 1st variable as a number and the 2nd a name to create directories. so if you typed in ./myscript 5 week, it would create 5 directories named week1 - week5. whenever i run this, i get an error message saying week5 already exists, so i... (3 Replies)
Discussion started by: layne2kim
3 Replies

5. UNIX for Dummies Questions & Answers

creating separate directories according to file extension and keeping file in different directory as

unix program to which a directory name will be passed as parameter. This directory will contain files with various extensions. This script will create directories with the names of the extention of the files and then put the files in the corresponding folder. All files which do not have any... (2 Replies)
Discussion started by: Deekay.p
2 Replies

6. Shell Programming and Scripting

Creating Directories

I have many pdf files with similar naming conventions as this one: AC41_AC85_86_AC128_129_MC171_173_SF_207_FMV.pdf. It is a pdf file containing evaluations for these locations: AC41, AC85, AC86, AC128, AC129, MC171, and MC173. I want to create a directory for every location and put the... (3 Replies)
Discussion started by: ndnkyd
3 Replies

7. Shell Programming and Scripting

help needed with creating challenging bash script with creating directories

Hi, Can someone help me with creating a bash shell script. I need to create a script that gets a positive number n as an argument. The script must create n directories in the current directory with names like map_1, map_2 etcetera. Each directory must be contained within its predecessor. So... (7 Replies)
Discussion started by: I-1
7 Replies

8. Shell Programming and Scripting

Creating date directory and moving files into that directory

I have list of files named file_username_051208_025233.log. Here 051208 is the date and 025233 is the time.I have to run thousands of files daily.I want to put all the files depending on the date of running into a date directory.Suppose if we run files today they should put into 05:Dec:08... (3 Replies)
Discussion started by: ravi030
3 Replies

9. HP-UX

creating directories on the same box

I have two login accounts 'fup04a' and 'fup04c' on the same unix box after log in using 'fup04a' and if I try creating a directory 'new' drwxrwxr-x 2 fup04a fup04a 4096 Nov 14 14:06 new but if i try the same with fup04c drw-rw-r-x 2 fup04c fup04c 4096 Nov 14... (3 Replies)
Discussion started by: vivek_damodaran
3 Replies

10. UNIX for Dummies Questions & Answers

creating directories

how do i create directories using command in my unix system, i could do with knowing how to do it with absolute pathnames and relative pathnames please (3 Replies)
Discussion started by: carlvernon
3 Replies
Login or Register to Ask a Question