gcloud alpha storage ls Stay organized with collections Save and categorize content based on your preferences.
- NAME
- gcloud alpha storage ls - list Cloud Storage buckets and objects
- SYNOPSIS
gcloud alpha storage ls[PATH…][--additional-headers=HEADER=VALUE][--all-versions,-a][--buckets,-b][--etag,-e][--exhaustive][--fetch-encrypted-object-hashes][--format=FORMAT][--metadata-filter=METADATA_FILTER][--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
(ALPHA)List your Cloud Storage buckets in a project and objects ina bucket. This command treats forward slashes in object names as directories.See below for examples of how to use wildcards to get the listing behavior youwant.- EXAMPLES
- The following command lists the buckets in the default project:
gcloudalphastoragelsThe following command lists the buckets in the specified project:
gcloudalphastoragels--project=my-projectThe following command lists the contents of a bucket:
gcloudalphastoragelsgs://my-bucketYou can usewildcards to matchmultiple paths (including multiple buckets). Bucket wildcards are expanded tomatch only buckets contained in your current project. The following commandmatches
objects that begin with.txtand that are stored in buckets in yourproject that begin withlog:my-bgcloudalphastoragelsgs://my-b*/log*.txtYou can use double-star wildcards to match zero or more directory levels in apath. The following command matches all
objects in a bucket..txtgcloudalphastoragelsgs://my-bucket/**/*.txtThe 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:gcloudalphastoragelsgs://my-bucket/**/dirDouble-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, thecommand
gs://my-bucket/dir**/log.txtis 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:gcloudalphastoragels--recursivegs://bucketRecursive listings are similar to
**except recursive listingsinclude line breaks and header formatting for each subdirectory.The following command filters objects based on specified filter while listing.Note that the flag is only supported for Google Cloud Storage URLs and onlyapplies to objects. This means that directories or buckets will still be listedeven if they do not contain objects that match the filter.
gcloudalphastoragelsgs://my-bucket--metadata-filter='contexts."foo"="bar"' - 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_headersproperty 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
--longoption, 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
--fullto get the full metadata of buckets. --etag,-e- Include ETag metadata in listings that use the
--longflag. --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.
--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 like
storage lsandstorage duwill 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. --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 helpfor 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:
gcloudstoragels
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.