LinuxQuestions.org
Help answer threads with 0 replies.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software
User Name
Password
Linux - Software This forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.

Notices

Reply
 
Search this Thread
Old 01-22-2004, 12:53 PM   #1
shanenin
Member
 
Registered: Aug 2003
Location: Rochester, MN, U.S.A
Distribution: Gentoo
Posts: 987

Rep: Reputation: 30
mkdir -p ?


I read the man pages about the command mkdir -p , I still am haveing trouble understanding it. Below is an excerpt from man mkdir
Quote:
-p, --parents
Make any missing parent directories for each directory argument.
The mode for parent directories is set to the umask modified by
`u+wx'. Ignore arguments corresponding to existing directories.
(Thus, if a directory /a exists, then `mkdir /a' is an error,
but `mkdir -p /a' is not.)
 
Old 01-22-2004, 01:07 PM   #2
ricstirato
Member
 
Registered: Jan 2004
Location: Gießen, Germany
Distribution: Xubuntu 12.04, Mythbuntu, Ubuntu Server 12.04
Posts: 174

Rep: Reputation: 24
Here is an example:

you already have a directory:

/a

you want a subdirectory c, which is in b, which is in a:

/a/b/c

A "mkdir /a/b/c" will fail, because it tries to create c in /a/b - and b does not yet exist.

You might use:

mkdir /a/b
mkdir /a/b/c

or simply

mkdir -p /a/b/c

which will create b, because it does not exist.
 
1 members found this post helpful.
Old 01-22-2004, 01:12 PM   #3
shanenin
Member
 
Registered: Aug 2003
Location: Rochester, MN, U.S.A
Distribution: Gentoo
Posts: 987

Original Poster
Rep: Reputation: 30
thanks you made that very clear. I always thought their had to be an easier way of making a directory then multilple mkdir commands.
 
Old 10-19-2011, 04:23 AM   #4
Fagadaba
LQ Newbie
 
Registered: Oct 2011
Posts: 1

Rep: Reputation: Disabled
Post 7 years later, from Google!

I am posting this here reply because this page is the first non-man answer for an "mkdir -p" query on Google.
To give some useful information/tip for all the noobs stumbling on here like I did.

You can use "mkdir -p" and the power of BRACES to create the biggest complexst hierarchies of directories you've ever dreamed of in one command!

Like so:
Code:
mkdir -p tmpdir/{trunk/sources/{includes,docs},branches,tags}
Which creates the following:
Code:
          tmpdir
    ________|______
   |        |      |
branches   tags  trunk
                   |
                 sources
               ____|_____
              |          |
          includes     docs
CRAZY HUH?!

Source: Wikipedia - mkdir

More info and examples here.

Last edited by Tinkster; 10-19-2011 at 11:40 AM. Reason: removed foul language
 
1 members found this post helpful.
Old 10-19-2011, 11:41 AM   #5
Tinkster
Moderator
 
Registered: Apr 2002
Location: in a fallen world
Distribution: slackware by choice, others too :} ... android.
Posts: 22,988
Blog Entries: 11

Rep: Reputation: 880Reputation: 880Reputation: 880Reputation: 880Reputation: 880Reputation: 880Reputation: 880
Introducing yourself to LQ by swearing in a necropost and
being reported for that. Nice. :}

And your version is simply a slightly more verbatious
explanation of the quote from the man-page in the first
response ...

Welcome, anyway.


Cheers,
Tink

Last edited by Tinkster; 10-19-2011 at 11:42 AM.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
mkdir recompilation puishor Programming 4 06-25-2005 04:37 PM
mkdir command digitalgravy Linux - General 5 08-12-2004 01:03 PM
mkdir help... Linux~Powered Linux - Software 2 06-13-2004 11:27 AM
mkdir doesn't work Kristian2 Slackware - Installation 7 06-10-2004 12:42 PM
mkdir help ITJedi Linux - Software 1 05-14-2004 05:19 PM


All times are GMT -5. The time now is 10:24 AM.

Main Menu
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration