Please note that the contents of this offline web site may be out of date. To access the most recent documentation visit the online version .
Note that links that point to online resources are green in color and will open in a new window.
We would love it if you could give us feedback about this material by filling this form (You have to be online to fill it)



du - Display object size usage

du - Display object size usage

Synopsis

gsutil du url...

Description

The du command displays the amount of space (in bytes) being used by the objects in the file or object hierarchy under a given URL. The syntax emulates the Linux du command (which stands for disk usage). For example, the command:

gsutil du -s gs://your-bucket/dir

will report the total space used by all objects under gs://your-bucket/dir and any sub-directories.

Options

-0 Ends each output line with a 0 byte rather than a newline. This can be useful to make the output more easily machine-readable.
-a Includes non-current object versions / generations in the listing (only useful with a versioning-enabled bucket). Also prints generation and metageneration for each listed object.
-c Produce a grand total.
-e A pattern to exclude from reporting. Example: -e “*.o” would exclude any object that ends in ”.o”. Can be specified multiple times.
-h Prints object sizes in human-readable format (e.g., 1KB, 234MB, 2GB, etc.)
-s Display only a summary total for each argument.
-X Similar to -e, but excludes patterns from the given file. The patterns to exclude should be one per line.

Examples

To list the size of all objects in a bucket:

gsutil du gs://bucketname

To list the size of all objects underneath a prefix:

gsutil du gs://bucketname/prefix/*

To print the total number of bytes in a bucket, in human-readable form:

gsutil du -ch gs://bucketname

To see a summary of the total bytes in the two given buckets:

gsutil du -s gs://bucket1 gs://bucket2

To list the size of all objects in a versioned bucket, including objects that are not the latest:

gsutil du -a gs://bucketname

To list all objects in a bucket, except objects that end in ”.bak”, with each object printed ending in a null byte:

gsutil du -e "\*.bak" -0 gs://bucketname

To get a total of all buckets in a project with a grand total for an entire project:

gsutil -o GSUtil:default_project_id=project-name du -shc

Authentication required

You need to be signed in with Google+ to do that.

Signing you in...

Google Developers needs your permission to do that.