【问题标题】:How to count the directories of a folder in two level in Linux?如何在Linux中计算两级文件夹的目录?
【发布时间】:2021-09-24 06:52:21
【问题描述】:

我只想计算文件夹的目录。例如:

我有这个结构:

  • 主文件夹
    • 文件夹

      • Folder_1
        • 另一个文件
    • 文件夹

      • 文件_2

        - Another_file
        
      • 文件_3

        - Another_file
        
        - Another_file
        

我需要一个只计算粗体文件的命令。在这种情况下,结果将是“3”。

这可能吗?

谢谢!

【问题讨论】:

    标签: linux ubuntu command debian


    【解决方案1】:

    你可以试试这个。希望有效

    find <path> -type d  -printf '%d\n' | grep 2 | wc -l
    

    %d 文件在目录树中的深度; 0 表示文件是 起点。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2012-02-27
      • 2023-03-28
      • 2015-06-28
      • 1970-01-01
      • 2014-01-20
      • 2020-10-07
      • 2014-01-31
      • 2021-08-25
      相关资源
      最近更新 更多