Possible Duplicate:
Get total size of folders with find & du
I can use du like this to get the file size of each file from stdin
find . -name "*.java" -exec du -h {} \;
But I can't get the total size.. Does anyone have ideas about that? Thanks!
Answered here:
How to get total size of folders with find and du?
Use xargs(1) instead of -exec:
find . -name bak -type d | xargs du -ch
executes the command for each file found (check the find(1) documentation). Piping to xargs lets you aggregate those filenames and only run du once.
In your case it would be:
find . -name "*.java" | xargs du -ch
Options:
-c, --total
produce a grand total
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With