Created
March 31, 2016 09:49
-
-
Save haojianzong/0ff36edf3836854546d37b6e7b8da4b6 to your computer and use it in GitHub Desktop.
Bash sum file sizes in folder group by file type
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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