counting number of directories in a specific directory

后端 未结 15 2257
被撕碎了的回忆
被撕碎了的回忆 2020-12-22 21:06

How to count the number of folders in a specific directory. I am using the following command, but it always provides an extra one.

find /directory/ -maxdept         


        
15条回答
  •  难免孤独
    2020-12-22 21:16

    Best way to navigate to your drive and simply execute

    ls -lR | grep ^d | wc -l
    

    and to Find all folders in total, including subdirectories?

    find /mount/point -type d | wc -l
    

    ...or find all folders in the root directory (not including subdirectories)?

    find /mount/point -maxdepth 1 -type d | wc -l
    

    Cheers!

提交回复
热议问题