如何在Linux上列出非空子目录? [英] How to list non-empty subdirectories on linux?

查看:179
本文介绍了如何在Linux上列出非空子目录?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个包含多个子目录的目录。我只想列出那些至少包含一个文件的子目录。我该怎么办?

I have a directory containing multiple subdirectories. I want to list only those subdirectories that contain at least one file. How can I do that?

推荐答案

 find . -mindepth 1 -maxdepth 1 -not -empty -type d

将为您提供所有非空目录。如果要排除仅包含其他目录(但不包含文件)的目录,则其他答案之一可能会更好...

will give you all nonempty directories. If you want to exclude directories that contain only other directories (but no files), one of the other answers might be better...

这篇关于如何在Linux上列出非空子目录?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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