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.

Revisions

  1. patricktrainer created this gist Sep 8, 2024.
    11 changes: 11 additions & 0 deletions get_data_size.sh
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,11 @@
    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
    }
    }'