Jump to content
Main menu
Main menu
move to sidebar
hide
Navigation
Main page
Recent changes
Random page
Help about MediaWiki
Special pages
Niidae Wiki
Search
Search
Appearance
Create account
Log in
Personal tools
Create account
Log in
Pages for logged out editors
learn more
Contributions
Talk
Editing
Mkdir
(section)
Page
Discussion
English
Read
Edit
View history
Tools
Tools
move to sidebar
hide
Actions
Read
Edit
View history
General
What links here
Related changes
Page information
Appearance
move to sidebar
hide
Warning:
You are not logged in. Your IP address will be publicly visible if you make any edits. If you
log in
or
create an account
, your edits will be attributed to your username, along with other benefits.
Anti-spam check. Do
not
fill this in!
==Usage== [[File:ReactOS-0.4.13 mkdir command 667x434.png|thumb|300px|The [[ReactOS]] <code>mkdir</code> command]] Normal usage is as straightforward as follows: <syntaxhighlight lang="bash"> mkdir name_of_directory </syntaxhighlight> where <code>name_of_directory</code> is the name of the directory one wants to create. When typed as above (i.e. normal usage), the new directory would be created within the current directory. On Unix and Windows (with Command extensions enabled,<ref>{{cite web|url=http://www.microsoft.com/resources/documentation/windows/xp/all/proddocs/en-us/mkdir.mspx?mfr=true|title=Microsoft Windows XP - Mkdir|publisher=Microsoft|archive-url=https://web.archive.org/web/20160722020802/http://www.microsoft.com/resources/documentation/windows/xp/all/proddocs/en-us/mkdir.mspx?mfr=true|archive-date=July 22, 2016|access-date=25 October 2012}}</ref> the default<ref>{{cite web|title=Microsoft Windows XP - Cmd|url=http://www.microsoft.com/resources/documentation/windows/xp/all/proddocs/en-us/cmd.mspx?mfr=true|publisher=Microsoft|access-date=25 October 2012}}</ref>), multiple directories can be specified, and <code>mkdir</code> will try to create all of them. ===Options=== On Unix-like operating systems, <code>mkdir</code> takes options. The options are: * <code>-p (--parents)</code>: ''parents'' or ''path'', will also create all directories leading up to the given directory that do not exist already. For example, <code>mkdir -p a/b</code> will create directory <code>a</code> if it doesn't exist, then will create directory <code>b</code> inside directory <code>a</code>. If the given directory already exists, ignore the error. * <code>-m (--mode)</code>: ''mode'', specify the [[File system permissions#Numeric notation|octal permissions]] of directories created by <code>mkdir</code> . <code>-p</code> is most often used when using <code>mkdir</code> to build up complex directory hierarchies, in case a necessary directory is missing or already there. <code>-m</code> is commonly used to lock down temporary directories used by [[shell script]]s. ===Examples=== An example of <code>-p</code> in action is: <syntaxhighlight lang="bash"> mkdir -p /tmp/a/b/c </syntaxhighlight> If <code>/tmp/a</code> exists but <code>/tmp/a/b</code> does not, <code>mkdir</code> will create <code>/tmp/a/b</code> before creating <code>/tmp/a/b/c</code>. And an even more powerful command, creating a full tree at once (this however is a [[shell (computing)|Shell]] extension, nothing mkdir does itself): <syntaxhighlight lang="bash"> mkdir -p tmpdir/{trunk/sources/{includes,docs},branches,tags} </syntaxhighlight> If one is using variables with mkdir in a bash script, [[POSIX]] `special' built-in command 'eval' would serve its purpose. <syntaxhighlight lang="bash"> DOMAIN_NAME=includes,docs eval "mkdir -p tmpdir/{trunk/sources/{${DOMAIN_NAME}},branches,tags}" </syntaxhighlight> This will create: <syntaxhighlight lang="text"> tmpdir ________|______ | | | branches tags trunk | sources ____|_____ | | includes docs </syntaxhighlight>
Summary:
Please note that all contributions to Niidae Wiki may be edited, altered, or removed by other contributors. If you do not want your writing to be edited mercilessly, then do not submit it here.
You are also promising us that you wrote this yourself, or copied it from a public domain or similar free resource (see
Encyclopedia:Copyrights
for details).
Do not submit copyrighted work without permission!
Cancel
Editing help
(opens in new window)
Search
Search
Editing
Mkdir
(section)
Add topic