gcloud storage ls

NAME
gcloud storage ls - list Cloud Storage buckets and objects
SYNOPSIS
gcloud storage ls[PATH …][--additional-headers=HEADER=VALUE][--all-versions,-a][--buckets,-b][--etag,-e][--exhaustive][--fetch-encrypted-object-hashes][--format=FORMAT][--next-page-token=NEXT_PAGE_TOKEN][--read-paths-from-stdin,-I][--readable-sizes][--recursive,-R,-r][--soft-deleted][--full,-L    |--json,-j    |--long,-l][--decryption-keys=[DECRYPTION_KEY,…]][GCLOUD_WIDE_FLAG]
DESCRIPTION
List your Cloud Storage buckets in a project and objects in a bucket. Thiscommand treats forward slashes in object names as directories. See below forexamples of how to use wildcards to get the listing behavior you want.
EXAMPLES
The following command lists the buckets in the default project:
gcloudstoragels

The following command lists the buckets in the specified project:

gcloudstoragels--project=my-project

The following command lists the contents of a bucket:

gcloudstoragelsgs://my-bucket

You can usewildcards to matchmultiple paths (including multiple buckets). Bucket wildcards are expanded tomatch only buckets contained in your current project. The following commandmatches.txt objects that begin withlog and that are stored in buckets in yourproject that begin withmy-b:

gcloudstoragelsgs://my-b*/log*.txt

You can use double-star wildcards to match zero or more directory levels in apath. The following command matches all.txt objects in a bucket.

gcloudstoragelsgs://my-bucket/**/*.txt

The wildcard** retrieves a flat list of objects in a single APIcall and does not match prefixes. The following command would not matchgs://my-bucket/dir/log.txt:

gcloudstoragelsgs://my-bucket/**/dir

Double-star expansion also can not be combined with other expressions in a givenpath segment and operates as a single star in that context. For example, thecommandgs://my-bucket/dir**/log.txt is treated asgs://my-bucket/dir*/log.txt. To get the recursive behavior, thecommand should instead be written the following way:

gs://my-bucket/dir*/**/log.txt

The following command lists all items recursively with formatting by using--recursive:

gcloudstoragels--recursivegs://bucket

Recursive listings are similar to** except recursive listingsinclude line breaks and header formatting for each subdirectory.

POSITIONAL ARGUMENTS
[PATH …]
The path of objects and directories to list. The path must begin with gs:// andis allowed to contain wildcard characters.
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
Include noncurrent object versions in the listing. This flag is typically onlyuseful for buckets withobjectversioning enabled. If combined with the--long option, themetageneration for each listed object is also included.
--buckets,-b
When given a bucket URL, only return buckets. Useful for avoiding the rule thatprints the top-level objects of buckets matching a query. Typically used incombination with--full to get the full metadata of buckets.
--etag,-e
Include ETag metadata in listings that use the--long flag.
--exhaustive
For features like soft delete, the API may return an empty list. If present,continue querying. This may incur costs from repeated LIST calls and may notreturn any additional objects.
--fetch-encrypted-object-hashes
API requests to the LIST endpoint do not fetch the hashes for encrypted objectsby default. If this flag is set, a GET request is sent for each encrypted objectin order to fetch hashes. This can significantly increase the cost of thecommand.
--format=FORMAT
Use "gsutil" to get the style of the older gsutil CLI. (e.g. "--format=gsutil").Other format values (e.g. "json") do not work. See different ls flags andcommands for alternative formatting.
--next-page-token=NEXT_PAGE_TOKEN
Page token for resuming LIST calls.
--read-paths-from-stdin,-I
Read the list of URLs from stdin.
--readable-sizes
When used with--long, print object sizes in human readable format,such as 1 KiB, 234 MiB, or 2 GiB.
--recursive,-R,-r
Recursively list the contents of any directories that match the path expression.
--soft-deleted
Displays soft-deleted resources only. For objects, it will exclude live andnoncurrent ones.
At most one of these can be specified:
--full,-L
List all available metadata about items in rows.
--json,-j
List all available metadata about items as a JSON dump.
--long,-l
For objects only. List size in bytes, creation time, and URL.
ENCRYPTION FLAGS
--decryption-keys=[DECRYPTION_KEY,…]
A comma-separated list of customer-supplied encryption keys (RFC 4648 section 4base64-encoded AES256 strings) that will be used to decrypt Cloud Storageobjects. Data encrypted with a customer-managed encryption key (CMEK) isdecrypted automatically, so CMEKs do not need to be listed here.
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 variant is also available:
gcloudalphastoragels

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-07-22 UTC.