Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/bash/16.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Linux 递归查找目录中的文件数_Linux_Bash_Shell_Command Line - Fatal编程技术网

Linux 递归查找目录中的文件数

Linux 递归查找目录中的文件数,linux,bash,shell,command-line,Linux,Bash,Shell,Command Line,递归查找目录中的文件数 例如,如果目录1有12个目录,而这12个目录中的每一个都有另外13个目录。 孙子目录13有固定数量的文件。 我怎么知道它有多少 我试图以以下方式可视化输出: a/b/1/ -- 50 files a/b/2/ -- 10 files a/c/1/ -- 20 files. 尝试: 找到-f型| wc-l 它统计find命令输出的输出行wc-l-键入f,在树中为每个文件输出一行 [编辑]在阅读了您的评论和更新后,我想到了以下一行: tree-idf-noreport |同

递归查找目录中的文件数

例如,如果目录1有12个目录,而这12个目录中的每一个都有另外13个目录。 孙子目录13有固定数量的文件。 我怎么知道它有多少

我试图以以下方式可视化输出:

a/b/1/ -- 50 files
a/b/2/ -- 10 files
a/c/1/ -- 20 files.
尝试:

找到-f型| wc-l

它统计find命令输出的输出行wc-l-键入f,在树中为每个文件输出一行

[编辑]在阅读了您的评论和更新后,我想到了以下一行:

tree-idf-noreport |同时读取行;不要重复$line;查找$line-maxdepth 1-type f | wc-l;完成

尝试:

找到-f型| wc-l

它统计find命令输出的输出行wc-l-键入f,在树中为每个文件输出一行

[编辑]在阅读了您的评论和更新后,我想到了以下一行:

tree-idf-noreport |同时读取行;不要重复$line;查找$line-maxdepth 1-type f | wc-l;完成

对于您的特定格式:

find . -type d -exec sh -c 'n=$(find "$0" -maxdepth 1 -type f -printf x | wc -c); printf "%s -- %s files\n" "$0" "$n"' {} \;
对于您的特定格式:

find . -type d -exec sh -c 'n=$(find "$0" -maxdepth 1 -type f -printf x | wc -c); printf "%s -- %s files\n" "$0" "$n"' {} \;

这只是给出了文件数量的输出。我想要每个文件夹。这个答案中有几个问题:树的输出不需要解析;如果空格缺少引号或其他有趣的符号换行符,则会非常失败。在这种情况下,我想它可以被find取代-然后输入d。无论如何,被接受的答案比我的要好得多:-这只是给出了文件数量的输出。我想要每个文件夹。这个答案中有几个问题:树的输出不需要解析;如果空格缺少引号或其他有趣的符号换行符,则会非常失败。在这种情况下,我想它可以被find取代-然后输入d。不管怎样,公认的答案比我的好得多:我是作者。我以为这是一种方法,我是作者。我以为这是一种方法。
for a in 1000000 1200000 1400000 1600000 1800000 2000000 2200000 2400000 800000
    do
    for b in 10 14 18 2 22 26 30 34 38 42 46 6
    do
        echo $a-$b
        find $a/$a-$b/ -type f -print | wc -l
    done
done