linux rmdir命令用法,Linux常用命令汇总--rmdir

1.功能:删除空目录。

2.用法:rmdir 参数 路径

3.参数:

-p :递归删除空目录,‘rmdir -p a/b/c’相当于执行了rmdir a/b/c a/b a’

4.例子

[root@mycentos home]# tree test

test

├── test_1

│   ├── test_1.txt

│   └── test_2

│       ├── test_2.txt

│       └── test_3

├── test_1.txt

└── test_4

└── test_5

例1:test_1下存在文件,不能通过rmdir命令删除;test_5下没有文件,可以通过rmdir命令删除;

[root@mycentos home]# rmdir test/test_4/test_5/

[root@mycentos home]# rmdir test/test_1

rmdir: 删除 "test/test_1" 失败: 目录非空

[root@mycentos home]# tree test

test

├── test_1

│   ├── test_1.txt

│   └── test_2

│       ├── test_2.txt

│       └── test_3

├── test_1.txt

└── test_4

例2:同时删除test_4、test_5、test_6三个文件夹

[root@mycentos test]# mkdir -p test/test_4/test_5/test_6

[root@mycentos test]# tree

.

├── test

│   └── test_4

│       └── test_5

│           └── test_6

├── test_1

│   ├── test_1.txt

│   └── test_2

│       ├── test_2.txt

│       └── test_3

└── test_1.txt

[root@mycentos test]# rmdir -p test/test_4/test_5/test_6/

[root@mycentos test]# tree

.

├── test_1

│   ├── test_1.txt

│   └── test_2

│       ├── test_2.txt

│       └── test_3

└── test_1.txt

test文件夹下的几个空文件夹都被删掉了。

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值