Linux 如何计算文件夹中的所有文件、其子文件夹和所有 . 计数不应包括文件夹计数
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/9769434/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
How to count all files inside a folder, its subfolder and all . The count should not include folder count
提问by Peter
How to count all files inside a folder, its subfolder and all . The count should not include folder count.
如何计算文件夹中的所有文件、其子文件夹和所有 . 计数不应包括文件夹计数。
I want to do it in MAC
我想在 MAC 上做
采纳答案by Jeff Foster
find . -type f | wc -l
will recursively list all the files (-type f
restricts to only files) in the current directory (replace .
with your path). The output of this is piped into wc -l
which will count the number of lines.
find . -type f | wc -l
将递归列出-type f
当前目录中的所有文件(仅限于文件)(替换.
为您的路径)。它的输出通过管道输送到wc -l
其中将计算行数。
回答by perreal
Find all files under myfolder
and count them using wc
. This works on linux:
查找所有文件myfolder
并使用wc
. 这适用于Linux:
find myfolder -type f | wc -l
find myfolder -type f | wc -l