Short command to find total size of files matching a wild card

前端 未结 3 2069
自闭症患者
自闭症患者 2021-02-18 14:04

I could envision a simple shell script that would accomplish what I want by just iterating through a list of files in a directory and summing the individual size but was wonderi

3条回答
  •  执念已碎
    2021-02-18 14:42

    Try du to summarize disk usage:

    du -csh *.jpg
    

    Output (for example):

    8.0K sane-logo.jpg
    16K sane-umax-advanced.jpg
    28K sane-umax-histogram.jpg
    24K sane-umax.jpg
    16K sane-umax-standard.jpg
    4.0K sane-umax-text2.jpg
    4.0K sane-umax-text4.jpg
    4.0K sane-umax-text.jpg
    104K total
    

    du does not summarize the size of the files but summarizes the size of the used blocks in the file system. If a file has a size of 13K and the file system uses a block size of 4K, then 16K is shown for this file.

提交回复
热议问题