Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
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