Skip to content

Instantly share code, notes, and snippets.

@patricktrainer
Created September 8, 2024 04:27
Show Gist options
  • Save patricktrainer/40181c4fdca5f50419a93411da733f30 to your computer and use it in GitHub Desktop.
Save patricktrainer/40181c4fdca5f50419a93411da733f30 to your computer and use it in GitHub Desktop.
the actual size of the data in a directory, not the size on disk.
find . -type f -print0 | xargs -0 stat -f "%z" | awk '{b+=$1} END {
if (b > 1073741824) {
printf "%.2f GB\n", b/1073741824
} else if (b > 1048576) {
printf "%.2f MB\n", b/1048576
} else if (b > 1024) {
printf "%.2f KB\n", b/1024
} else {
printf "%d bytes\n", b
}
}'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment