常用命令:mkdir的使用

mkdir用来创建文件夹。如mkdir temp会在当前目录创建名为temp的文件夹。
虽然mkdir是个很常用的命令,我个人对它的参数却不熟悉,很少用到。因此写此文总结一下。

用法

mkdir [-pv] [-m mode] directory_name …

题外话:上面的中括号标识可选参数。-pv也是两个可选参数,不必同时出现。

参数解释

-p: 距离来说在创建a/b/c这样的目录时候,加入文件夹b不存在,默认情况是是会报错“mkdir: a/b: No such file or directory”的。但加入-p参数则能自动创建路径中不存在的文件夹并成功运行。

-v: 在文件夹成功创建后,给出文字提示。示例如下:

mkdir -v a
mkdir: created directory ‘a’

-m: 由于对chmod命令的使用还不熟悉,这部分解释待日后补充。

Set the file permission bits of the final created directory to the specified mode. The mode argument can be in any of the formats specified to the chmod(1) command. If a symbolic mode is specified, the operation characters “+” and “-“ are interpreted relative to an initial mode of ``a=rwx’’.