查找空目录 [英] Finding empty directories

查看:71
本文介绍了查找空目录的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要找到给定目录列表的空目录.有些目录中有目录.

I need to find empty directories for a given list of directories. Some directories have directories inside it.

如果内部目录也是空的,我可以说主目录是空的,否则它不是空的.

If inside directories are also empty I can say main directory is empty otherwise it's not empty.

我该如何测试?

例如:

A>A1(file1),A2 this is not empty beacuse of file1
B>B1(no file) this is empty
C>C1,C2 this is empty

推荐答案

检查是否找到了< dir>-type f 输出任何内容.这是一个示例:

Check whether find <dir> -type f outputs anything. Here's an example:

for dir in A B C; do
    [ -z "`find $dir -type f`" ] && echo "$dir is empty"
done

这篇关于查找空目录的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆