Unix find average file size

前端 未结 7 2372
忘掉有多难
忘掉有多难 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:00

    Use du to estimate file space usage for a given directory.

    du -sh /Your/Path # Average file size in human readable format
    

    -s (--summarize) display only a total for each argument.

    -h (--human-readable) print sizes in human readable format (e.g. 1K, 234M, 2G).

    Note that not using -h would give the default block size (512-byte blocks).

    If you wish to specify the block size you can use -k (Kilobytes), -m (Megabytes), or -g (Gigabytes).

    du -sk /Your/Path # Average file size in Kilobytes.
    

    Footnote: Using a file path would give the specified files's size.

提交回复
热议问题