8.4.22 mkdir command (creates directories)
Syntax
mkdir [-p] [-m permissions] directory ...
Description
This command creates directories.
Arguments
- -p
Specifies that missing intermediate directories are to be created as needed.
- -m permissions
In UNIX, specifies permissions that are to be set for the created directories. The umask value is not applied.
You can specify the permissions either as an octal number or using symbols.
If you specify a number, an error occurs if you specify a non-octal number or an octal value greater than 07777 (4095 decimal).
If you specify symbols, do so by setting, adding, and removing permissions, starting from the state in which nothing is specified (0 in numeric representation).
A symbol consists of three parts. Specify one or more of the symbols, as explained below. If you specify more than one, separate them with the comma (,).
Order within the symbol
Permitted value
First
Specifies the items for which you want to set access permissions. You can specify more than one at the same time. The items below can be specified. If nothing is specified, a (all users) is assumed.
u: Owner
g: Group
o: Other
a: All users
Second
Specifies an operation on the mode. The following processing is performed on the items specified in the first part of a symbol.
=: Set (overwrite) access permissions.
+: Add access permissions.
-: Remove access permissions.
The value to be set, added, or removed is specified in the third part of the symbol.
You can specify the second and third parts of a symbol following the third part. The third part of a symbol can be omitted.
Third
Specifies the applicable access permissions. You can specify more than one at the same time. The following values can be specified:
r: Read.
w: Write.
x: Execute.
s: Set the user ID or group ID at run time.
t: Sticky bit
u: Owner access permissions currently set in the mode.
g: Group access permissions currently set in the mode.
o: Other access permissions currently set in the mode.
When this part is omitted and = is specified in the second part of the symbol, the items for which access permissions are set are cleared. When this part is omitted and + or - is specified in the second part of the symbol, no processing occurs.
Specifying s or t in this part will be ignored if only o is specified in the first part.
The following table shows examples of specifying symbols:
Value specified in -m
Numeric equivalent
Description
u=x, g=w
120
Set u to x, and set g to w.
u=x, g=u
110
Set u to x, and set the same values for g and u.
u=x, =u
111
Set u to x, and then set a (the default value) to the same values as u.
u=x, u=w
200
Set u to x, and then set (overwrite) u to w.
u=x, u+w
300
Set u to x, and then add w to u.
ug=x
110
Set u and g to x.
u=rw
600
Set u to r and w.
u=r+x
500
Set u to r, and then add x.
u=r=w
200
Set u to r, and then set (overwrite) it to w.
=x, u=
011
Set a (the default value) to x, and clear the settings for u.
=
000
Clear a (the default value).
In Windows, this specification is ignored.
- directory
Specifies a name for a directory to be created. Multiple directory names can be specified.
Return codes
Return code |
Meaning |
---|---|
0 |
Normal termination |
1 or greater |
Error termination |
Notes
In Windows, the -m option is ignored. The mode cannot be specified.
Examples
Create directory Dir2 under C:\USR\JP1.
C:\TEMP>%ADSH_OSCMD_DIR%\mkdir C:\USR\JP1\Dir2
Display an option error message.
This message might vary depending on the platform on which the command is executed. The following shows an example in Windows:
C:\TEMP>%ADSH_OSCMD_DIR%\mkdir -w mkdir: illegal option -- w usage: mkdir [-p] [-m mode] directory ...