linux 中 mkdir -p选项

发布时间 2023-11-25 12:15:15作者: 小鲨鱼2018

 

mkdir -p选项保证在创建目录的时没有上一级目录情况下自动创建

001、不加 -p选项

(base) [root@pc1 test]# ls
(base) [root@pc1 test]# mkdir test01/test02       ## 不加 -p, 创建两级目录,失败
mkdir: cannot create directory ‘test01/test02’: No such file or directory
(base) [root@pc1 test]# ls

 

002、增加 -p选项

(base) [root@pc1 test]# ls
(base) [root@pc1 test]# mkdir -p test01/test02    ## 增加-p, 创建两级目录,创建成功
(base) [root@pc1 test]# ls
test01
(base) [root@pc1 test]# tree
.
└── test01
    └── test02

2 directories, 0 files

 。