How to remove all the empty files or directories?

本文介绍了一种使用Linux命令find和xargs批量删除指定目录下所有空文件及目录的方法,通过设置条件来匹配并删除空目录。
<?xml version="1.0" encoding="utf-8"?> How to remove all the empty files or directories?

How to remove all the empty files or directories?

I am confused why I get many empty directories inside my Downloads directory, and I have to remove all of the empty ones. Here is what I did:

find home/wujing/Downloads -empty -type d -delete

The -type option tells find to match only directories, another similar option is -type f which matches regular files. The -delete option will actually delete all of the matched items.

The xargs can do the same job.

find run/shm -type d -empty -print0xargs -0 -I {} rmdir "{}"

Author: wujing

Created: 2014-10-22 三 10:02

Emacs 24.3.1 (Org mode 8.2.6)

Validate

转载于:https://www.cnblogs.com/wujingcqu/p/4042372.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值