Calculating files size in bash

When we face the problem of calculating size of some files then we often think of du.. But how could we count size of files found by find? We could do this with this simple one-liner:

Find command is simple here. We use here also a POSIX solution – ending “exec” with a plus-sign not a semicolon. This form groups the finding results into sets and then run commands on whole that set. And that’s why we use it here – our wc -c command is run on a whole set of results giving us in the end line the total size of all the files:

We could shorten that a little:

And If we would like to have only the number: