linux - 如何计算每个目录中的文件数?

我可以列出所有目录

find ./ -type d

我尝试使用以下命令列出每个目录的内容并统计每个目录中的文件数

find ./ -type d | xargs ls -l | wc -l

但是这总结了返回的总行数

find ./ -type d | xargs ls -l

有没有办法统计每个目录中的文件数?

最佳答案

这会打印当前目录级别的每个目录的文件计数:

du -a | cut -d/ -f2 | sort | uniq -c | sort -nr

https://stackoverflow.com/questions/15216370/

相关文章:

python - 在类方法上使用 property()

android - Ubuntu - 错误 : Failed to create the SD ca

python - 定义Python源代码编码的正确方法

python - 在pytest中,conftest.py文件有什么用?

Linux - 替换文件名中的空格

linux - 如何从文本文件中删除换行符?

python - Python中的字符串如何格式化 boolean 值?

python - 导入语句python3的变化

linux - 安装 Jenkins 后无法 su 到用户 jenkins

linux - 错误 : Can't open display: (null) when using