寻找空目录UNIX [英] Finding empty directories UNIX
本文介绍了寻找空目录UNIX的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我需要找到空目录的目录给定的名单。
有些目录有目录里面。
如果目录里面也空,我可以说主目录是空的,否则它不是空的。
如何测试呢?
例如:
A> A1(文件1),A2这不是文件1空怎么一回事,因为
B个B1(无文件),这是空
c取代; C1,C2这是空
解决方案
检查是否找到< DIR>型的F
输出任何东西,这里有一个例子:
在A B C目录;做
[-z`$找到DIR型F`]&放大器;&安培;回声$ dir是空
DONE
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.
How can I test this?
For example:
A>A1(file1),A2 this is not empty beacuse of file1
B>B1(no file) this is empty
C>C1,C2 this is empty
解决方案
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
这篇关于寻找空目录UNIX的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文