Skip to content

Instantly share code, notes, and snippets.

@haojianzong
Created March 31, 2016 09:49
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save haojianzong/0ff36edf3836854546d37b6e7b8da4b6 to your computer and use it in GitHub Desktop.
Save haojianzong/0ff36edf3836854546d37b6e7b8da4b6 to your computer and use it in GitHub Desktop.
Bash sum file sizes in folder group by file type
#!/bin/bash
types=($(find . -type f -name '*.*' | sed 's|.*\.||' | sort -u))
IFS=$'\n';
for type in ${types[@]}; do
sum=$(find . -type f -name "*.$type" -exec du -ch {} + | grep total$)
echo "$type : $sum"
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment