How do I get total space of filenames matching a pattern?


I am trying to get the total disk usage of log files under a folder using find | du -s. du is not summarizing.

find ${ROOT_FOLDER} -name "*.log" -print0 | du -hs --files0-from=-

The command lists every matching file and the disk usage of the file. No summary for all files.

Are there additional options that can be specified to the summary for all files?


You want -c (so, with your other switches, -hsc ) which should provide a grand total for du (see

/ # find / -name "*.log" -print0 |  du -hs --files0-from=-
1.0M    /tmp/1.log
2.0M    /var/log/2.log
/ # find / -name "*.log" -print0 |  du -hsc --files0-from=-
1.0M    /tmp/1.log
2.0M    /var/log/2.log
3.0M    total

Answered By – erik258

This Answer collected from stackoverflow, is licensed under cc by-sa 2.5 , cc by-sa 3.0 and cc by-sa 4.0

Leave a Reply

(*) Required, Your email will not be published