Unix find average file size

前端 未结 7 2375
忘掉有多难
忘掉有多难 2020-12-13 09:23

I have a directory with a ton of files I want to find the average file size of these files so something like ls somethinghere whats the average file size of everyth

7条回答
  •  别那么骄傲
    2020-12-13 10:08

    A short, general and recursion-friendly variation of Ernstsson's answer:

    find ./ -ls | awk '{sum += $7; n++;} END {print sum/n;}'
    

    Or, for example, if you want to impede files above 100 KB from stewing the average:

    find ./ -size -100000c -ls | awk '{sum += $7; n++;} END {print sum/n;}'
    

提交回复
热议问题