Tag Archives: bash

OS X terminal tip: get total bytes in all files in this folder

So, you want to know exactly how many bytes are in all of the files under a given directory, and you only have a Mac OS X terminal to work with?

It should be easy, but it’s not.

Here, I’ll save you some time:

find . -type f -not -iname .ds_store -print0 | xargs -0 stat -f %z | awk '{s+=$1} END {print s}'

Of course I’m assuming you don’t want any of those nasty .DS_Store files to be counted.