每天一命令(4) rmdir (remove empty directories) 1分钟

rmdir (remove empty directories)

man rmdir 查看使用文档

NAME
       rmdir - remove empty directories
SYNOPSIS
       rmdir [OPTION]... DIRECTORY...
DESCRIPTION
       Remove the DIRECTORY(ies), if they are empty.
       --ignore-fail-on-non-empty

              ignore each failure that is solely because a directory

              is non-empty

       -p, --parents
              remove DIRECTORY and its ancestors; e.g., ‘rmdir -p a/b/c’ is similar to ‘rmdir a/b/c a/b a’

       -v, --verbose
              output a diagnostic for every directory processed

       --help display this help and exit

       --version
              output version information and exit
创建空文件夹,并且移除 mkdir java rmdir java
root@guofeng  ~
mkdir java

root@guofeng  ~
rmdir -v java
rmdir: removing directory, `java'
rmdir 只能移除空文件
root@guofeng  ~
 mkdir java

root@guofeng  ~
cd java

root@guofeng  ~/java
touch java.txt

root@guofeng  ~/java
cd ..

root@guofeng  ~
rmdir java
rmdir: failed to remove `java': Directory not empty
rmdir -pv 移除多层级文件夹,如果文件里面内容,就不能删除
root@guofeng  ~
mkdir -p java/com/seckill/domain

root@guofeng  ~
ll java/com/seckill/domain/
total 0

root@guofeng  ~
 ls -a java/com/seckill/domain/
.  ..

root@guofeng  ~
rmdir -p java/
com/      java.txt  

root@guofeng  ~
rmdir -vp java/com/seckill/domain/

rmdir: removing directory, `java/com/seckill/domain/'
rmdir: removing directory, `java/com/seckill'
rmdir: removing directory, `java/com'
rmdir: removing directory, `java'
rmdir: failed to remove directory `java': Directory not empty

root@guofeng  ~
ll
total 76
-rw-------. 1 root root  2404 Nov  8  2014 anaconda-ks.cfg
-rw-r--r--  1 root root     0 Jun  6 18:47 b-ba-c.txt
-rw-r--r--  1 root root   479 Jun  7 22:12 dump.rdb
-rw-r--r--  1 root root     0 May 17 07:00 EOF
drwxr-xr-x  4 root root  4096 Jun  8 01:17 guofeng
-rw-r--r--. 1 root root 39004 Nov  8  2014 install.log
-rw-r--r--. 1 root root  9154 Nov  8  2014 install.log.syslog
drwxr-xr-x  2 root root  4096 Jun  9 19:23 java
drwxrwxrwx  2 root root  4096 Jun  7 18:22 test

root@guofeng  ~
cd java

root@guofeng  ~/java
ll
total 0
-rw-r--r-- 1 root root 0 Jun  9 19:20 java.txt

root@guofeng  ~/java
ll
total 0
-rw-r--r-- 1 root root 0 Jun  9 19:20 java.txt
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值