-
-
Save kkew3/46b32c1d7fcd601ff67ff68a00eb3e99 to your computer and use it in GitHub Desktop.
sum human readable file sizes from `du` with `numfmt` and `perl`
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Require: [`fd`](https://github.com/sharkdp/fd.git) | |
PATTERN='XXX' # Assume this would be a directory | |
fd -0 -td "$PATTERN" \ | |
| xargs -0 du -sh \ | |
| numfmt --from=auto --to=none \ | |
| perl -ane 'BEGIN { my $sum = 0; } $sum += $F[0]; print; END { print $sum, " totoal\n"; }' \ | |
| numfmt --from=none --to=si |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment