Posted By

alfirth on 11/16/15


Tagged


Versions (?)

list of filetypes by size


 / Published in: Bash
 

URL: http://serverfault.com/questions/367185/calculating-total-file-size-by-extension-in-shell

on OSX brew install coreutils; brew install ack adapted from http://serverfault.com/questions/367185/calculating-total-file-size-by-extension-in-shell

  1. #!/bin/bash
  2.  
  3.  
  4. ftypes=$(find . -type f | grep -E ".*\.[a-zA-Z0-9]*$" | sed -e 's/.*\(\.[a-zA-Z0-9]*\)$/\1/' | sort | uniq)
  5.  
  6. for ft in $ftypes
  7. do
  8. echo -ne "$ft\t"
  9. find . -name "*${ft}" -exec gdu -bcsh '{}' + | tail -1 | sed 's/\stotal//' | ack '\dM' | sort -k 2 -nr
  10. done

Report this snippet  

You need to login to post a comment.