How to calculate the total size of certain files only, recursive, in linux

后端 未结 3 1891
攒了一身酷
攒了一身酷 2020-12-29 12:27

I\'ve got a bunch of files scattered across folders in a layout, e.g.:

dir1/somefile.gif
dir1/another.mp4
dir2/video/filename.mp4
dir2/some.file
dir2/blahbla         


        
3条回答
  •  轻奢々
    轻奢々 (楼主)
    2020-12-29 12:59

    For individual file size:

    find . -name "*.mp4" -print0 | du -sh --files0-from=- 
    

    For total disk space in GB:

    find . -name "*.mp4" -print0 | du -sb --files0-from=-  | awk '{ total += $1} END { print total/1024/1024/1024 }'
    

提交回复
热议问题