How to count number of files in each directory?

前端 未结 17 2724
小蘑菇
小蘑菇 2020-12-07 07:05

I am able to list all the directories by

find ./ -type d

I attempted to list the contents of each directory and count the number of files i

17条回答
  •  感情败类
    2020-12-07 08:09

    find . -type f | cut -d/ -f2 | sort | uniq -c
    
    • find. -type f to find all items of the type file
    • cut -d/ -f2 to cut out their specific folder
    • sort to sort the list of foldernames
    • uniq -c to return the number of times each foldername has been counted

提交回复
热议问题