Mkdir

1

The** **** **** (make directory) command in the Unix, DOS, DR FlexOS, IBM OS/2, Microsoft Windows, and ReactOS operating systems is used to ****make a new ****dir**ectory. It is also available in the EFI shell and in the PHP scripting language. In DOS, OS/2, Windows and ReactOS, the command is often abbreviated to. The command is analogous to the Stratus OpenVOS command. MetaComCo TRIPOS and AmigaDOS provide a similar command to create new directories. The numerical computing environments MATLAB and GNU Octave include an function with similar functionality.

History

In early versions of Unix (4.1BSD and early versions of System V), this command had to be setuid root as the kernel did not have an syscall. Instead, it made the directory with and linked in the and directory entries manually. The command is available in MS-DOS versions 2 and later. Digital Research DR DOS 6.0 and Datalight ROM-DOS also include an implementation of the md and mkdir commands. The version of bundled in GNU coreutils was written by David MacKenzie. It is also available in the open source MS-DOS emulator DOSBox and in KolibriOS.

Usage

Normal usage is as straightforward as follows: where 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, the default ), multiple directories can be specified, and will try to create all of them.

Options

On Unix-like operating systems, takes options. The options are: is most often used when using to build up complex directory hierarchies, in case a necessary directory is missing or already there. is commonly used to lock down temporary directories used by shell scripts.

Examples

An example of in action is: If exists but does not, will create before creating. And an even more powerful command, creating a full tree at once (this however is a Shell extension, nothing mkdir does itself): If one is using variables with mkdir in a bash script, POSIX `special' built-in command 'eval' would serve its purpose. This will create:

This article is derived from Wikipedia and licensed under CC BY-SA 4.0. View the original article.

Wikipedia® is a registered trademark of the Wikimedia Foundation, Inc.
Bliptext is not affiliated with or endorsed by Wikipedia or the Wikimedia Foundation.

Edit article