How to report number of files in all subdirectories?

回覆文章
yehlu
Site Admin
文章: 3245
註冊時間: 2004-04-15 17:20:21
來自: CodeCharge Support Engineer

How to report number of files in all subdirectories?

文章 yehlu »

http://unix.stackexchange.com/questions ... irectories

代碼: 選擇全部

for f in *; do [ -d ./"$f" ] && find ./"$f" -maxdepth 1 -exec echo \; | wc -l && echo $f; done
yehlu
Site Admin
文章: 3245
註冊時間: 2004-04-15 17:20:21
來自: CodeCharge Support Engineer

目錄裡有多少個JPG

文章 yehlu »

http://stackoverflow.com/questions/6286 ... ile-counts

代碼: 選擇全部

find -maxdepth 1 -type d | while read dir; do 
    count=$(find "$dir" -maxdepth 1 -iname \*.jpg | wc -l)
    echo "$dir ; $count"
done

代碼: 選擇全部

find -maxdepth 1 -type d | while read dir; do 
    count=$(find "$dir" -maxdepth 1 -iname \* | wc -l)
    echo "$dir ; $count"
done
回覆文章

回到「Linux」