du
find
size
total

[Linux] Count the total size of special files

More than 1 year has passed since last update.

If you want to count the total size of special files. For example if you want to calculate the total size of files which name includes "daily". Then you can use this command to get the result.

find . -name "*daily*" | xargs du -ch

This will list all the files which name includes "daily" and count the total size of these files.

The output will like this:

4.0K    ./2016_06_28_daily.log
4.0K    ./2016_06_29_daily.log
4.0K    ./2016_06_30_daily.log
4.0K    ./2016_07_01_daily.log
4.0K    ./2016_07_02_daily.log
4.0K    ./2016_07_03_daily.log
 24K    total

If you have some better methods, please tell me :)