我需要计算大量目录上的文件数。是否有使用 shell 脚本(使用 find、wc、sed、awk 或类似工具)的简单方法?只是为了避免必须在 python 中编写适当的脚本。
输出将是这样的:
$ <magic_command>
dir1 2
dir2 12
dir3 5
目录名称后面的数字将是文件数。加号将能够打开和关闭点/隐藏文件的计数。
谢谢!
最佳答案
试试下面的一个:
du -a | cut -d/ -f2 | sort | uniq -c | sort -nr
来自 http://www.linuxquestions.org/questions/linux-newbie-8/how-to-find-the-total-number-of-files-in-a-folder-510009/#post3466477
关于shell - 计算每个目录中文件数的脚本,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13757896/