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?
CodePudding user response:
You want -c
(so, with your other switches, -hsc
) which should provide a grand total for du (see man7.org/linux/man-pages/man1/du.1.html)
/ # 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