Skip to content

Instantly share code, notes, and snippets.

@silvein
Created April 13, 2011 02:47
Show Gist options
  • Save silvein/916874 to your computer and use it in GitHub Desktop.
Save silvein/916874 to your computer and use it in GitHub Desktop.
This is a one-liner to sum the total size of all files (in gigabytes) in a specific directory and period (monthly).
#!/bin/bash
find $1 -type f -printf "%CY%Cm %s %p\n" |
/usr/bin/awk '{ total[$1] += $2 } END { for (period in total) printf "%s: %f\n", period, total[period]/1024^3 }' |
sort
@silvein
Copy link
Author

silvein commented Apr 13, 2011

Output looks like this:

201006: 5.515946
201007: 6.434511
201008: 6.302867
201009: 4.725753
201010: 5.163738
201011: 4.569330
201012: 7.170505
201101: 5.824497
201102: 4.209730
201103: 4.658753
201104: 2.286961

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment