Reputation: 37
I am using gcloud version 'Google Cloud SDK 204.0.0' I need to get the total size in tb of all the buckets in my project. I am bound to use cloud SDK version 204.0.0 which is older one. How to get the total volume of one/all my buckets in one project?
Upvotes: 0
Views: 650
Reputation: 4913
gsutil du
will get you the the sized of all files in all buckets
gsutil du -s
will get you the sized of each bucket
gsutil du -s | awk '{s+=$1}END{print s}'
will get you the sum of all the buckets in bytes
gsutil du -s | awk '{s+=$1}END{printf "%.10g TB\n", s/1000000000000}'
will get you the sum of all the buckets in TB
UPD 1 (add power shell version for Windows user):
I am probably butchering it, but here is my attempt to "Google Translate" from awk to PS:
gsutil du -s | %{ [Decimal]$s+=$_.Split(' ')[0]/1000000000000; } ; Write-Host "$s TB" ; Clear-Variable -Name "s"
UPD 2 (add the exponent of 10):
finally you can change 1000000000000
to 1e12
Upvotes: 4