How to calculate the space used by files in Linux?

Suppose that you want to calculate the space used by all the png files in current directory and all its subdirectories. From a terminal type:
find . -name '*.png' -exec du -ab {} \; | awk '{total+=$0}END{print total}'
Comments