gcloud alpha storage du

NAME
gcloud alpha storage du - displays the amount of space in bytes used by storage resources
SYNOPSIS
gcloud alpha storage du[URL …][--additional-headers=HEADER=VALUE][--all-versions,-a][--exclude-name-pattern=EXCLUDE_NAME_PATTERN,-eEXCLUDE_NAME_PATTERN][--exclude-name-pattern-file=EXCLUDE_NAME_PATTERN_FILE,-XEXCLUDE_NAME_PATTERN_FILE][--metadata-filter=METADATA_FILTER][--readable-sizes,-r][--summarize,-s][--total,-c][--zero-terminator,-0][GCLOUD_WIDE_FLAG]
DESCRIPTION
(ALPHA) Displays the amount of space in bytes used by the objectsin a bucket, subdirectory, or project. This command calculates the current spaceusage by making a series of object listing requests, which can take a long timefor large buckets. If your bucket contains hundreds of thousands of objects, orif you want to monitor your bucket size over time, use Monitoring instead, asdescribed inGet bucketsize
EXAMPLES
To list the size of each object in a bucket:
gcloudalphastoragedugs://bucketname

To list the size of each object in the prefix subdirectory:

gcloudalphastoragedugs://bucketname/prefix/*

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

gcloudalphastoragedu-cgs://bucketname

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

gcloudalphastoragedu-sgs://bucket1gs://bucket2

To list the size of each object in a bucket with Object Versioning enabled,including noncurrent objects:

gcloudalphastoragedu-ags://bucketname

To list the size of each object in a bucket, except objects that end in ".bak",with each object printed ending in a null byte:

gcloudalphastoragedu-e"*.bak"-0gs://bucketname

To list the size of each bucket in a project and the total size of the project:

gcloudalphastoragedu--summarize--readable-sizes--total

The following command summarizes the size of objects that match the specifiedfilter.

gcloudalphastoragedugs://my-bucket--metadata-filter='contexts."foo"="bar"'--summarize
POSITIONAL ARGUMENTS
[URL …]
The url of objects to list.
FLAGS
--additional-headers=HEADER=VALUE
Includes arbitrary headers in storage API calls. Accepts a comma separated listof key=value pairs, e.g.header1=value1,header2=value2. Overridesthe defaultstorage/additional_headers property value for thiscommand invocation.
--all-versions,-a
Includes noncurrent object versions for a bucket with Object Versioning enabled.Also prints the generation and metageneration number for each listed object.
--exclude-name-pattern=EXCLUDE_NAME_PATTERN,-eEXCLUDE_NAME_PATTERN
Exclude a pattern from the report. Example:-e "*.o" excludes anyobject that ends in ".o". Can be specified multiple times.
--exclude-name-pattern-file=EXCLUDE_NAME_PATTERN_FILE,-XEXCLUDE_NAME_PATTERN_FILE
Similar to -e, but excludes patterns from the given file. The patterns toexclude should be listed one per line.
--metadata-filter=METADATA_FILTER
Server side filtering for objects. Works only for Google Cloud Storage URLs. Thefilter only works for objects, and not directories or buckets, which meanscommands likestorage ls andstorage du will stilllist directories or buckets even if they do not contain any objects matching thefilter. Seehttps://cloud.google.com/storage/docs/listing-objects#filter-by-object-contexts-syntaxfor more details.
--readable-sizes,-r
Prints object sizes in human-readable format. For example, 1 KiB, 234 MiB, or2GiB.
--summarize,-s
Displays only the summary for each argument.
--total,-c
Includes a total size of all input sources.
--zero-terminator,-0
Ends each output line with a 0 byte rather than a newline. You can use this tomake the output machine-readable.
GCLOUD WIDE FLAGS
These flags are available to all commands:--access-token-file,--account,--billing-project,--configuration,--flags-file,--flatten,--format,--help,--impersonate-service-account,--log-http,--project,--quiet,--trace-token,--user-output-enabled,--verbosity.

Run$gcloud help for details.

NOTES
This command is currently in alpha and might change without notice. If thiscommand fails with API permission errors despite specifying the correct project,you might be trying to access an API with an invitation-only early accessallowlist. This variant is also available:
gcloudstoragedu

Except as otherwise noted, the content of this page is licensed under theCreative Commons Attribution 4.0 License, and code samples are licensed under theApache 2.0 License. For details, see theGoogle Developers Site Policies. Java is a registered trademark of Oracle and/or its affiliates.

Last updated 2025-10-07 UTC.