gcloud storage rm (original) (raw)
Cloud Client Libraries
Google Cloud CLI
gcloud Reference
- Overview
- gcloud access-approval
- gcloud access-context-manager
- gcloud active-directory
- gcloud ai
- gcloud ai-platform
- gcloud alloydb
- gcloud alpha
- gcloud anthos
- gcloud api-gateway
- gcloud apigee
- gcloud apihub
- gcloud app
- gcloud apphub
- gcloud artifacts
- gcloud asset
- gcloud assured
- gcloud audit-manager
- gcloud auth
- gcloud backup-dr
- gcloud batch
- gcloud beta
- gcloud beyondcorp
- gcloud biglake
- gcloud bigtable
- gcloud billing
- gcloud bms
- gcloud bq
- gcloud builds
- gcloud certificate-manager
- gcloud cheat-sheet
- gcloud cloud-shell
- gcloud cloudlocationfinder
- gcloud colab
- gcloud compliance-manager
- gcloud components
- gcloud composer
- gcloud compute
- gcloud config
- gcloud container
- gcloud data-catalog
- gcloud database-migration
- gcloud dataflow
- gcloud datalineage
- gcloud dataplex
- gcloud dataproc
- gcloud datastore
- gcloud datastream
- gcloud deploy
- gcloud deployment-manager
- gcloud design-center
- gcloud developer-connect
- gcloud dns
- gcloud docker
- gcloud domains
- gcloud edge-cache
- gcloud edge-cloud
- gcloud emulators
- gcloud endpoints
- gcloud essential-contacts
- gcloud eventarc
- gcloud feedback
- gcloud filestore
- gcloud firebase
- gcloud firestore
- gcloud functions
- gcloud gemini
- gcloud healthcare
- gcloud help
- gcloud iam
- gcloud iap
- gcloud identity
- gcloud ids
- gcloud info
- gcloud infra-manager
- gcloud init
- gcloud kms
- gcloud logging
- gcloud looker
- gcloud lustre
- gcloud managed-kafka
- gcloud memcache
- gcloud memorystore
- gcloud metastore
- gcloud migration
- gcloud ml
- gcloud model-armor
- gcloud monitoring
- gcloud netapp
- gcloud network-connectivity
- gcloud network-management
- gcloud network-security
- gcloud network-services
- gcloud notebooks
- gcloud observability
- gcloud oracle-database
- gcloud org-policies
- gcloud organizations
- gcloud pam
- gcloud parametermanager
- gcloud policy-intelligence
- gcloud policy-troubleshoot
- gcloud preview
- gcloud privateca
- gcloud projects
- gcloud publicca
- gcloud pubsub
- gcloud recaptcha
- gcloud recommender
- gcloud redis
- gcloud resource-manager
- gcloud run
- gcloud scc
- gcloud scheduler
- gcloud secrets
- gcloud service-directory
- gcloud service-extensions
- gcloud service-health
- gcloud services
- gcloud source
- gcloud source-manager
- gcloud spanner
- gcloud sql
- gcloud storage
* Overview
* buckets
* Overview
* add-iam-policy-binding
* create
* delete
* describe
* get-iam-policy
* list
* relocate
* remove-iam-policy-binding
* set-iam-policy
* update
* cat
* cp
* diagnose
* du
* hash
* ls
* mv
* restore
* rm
* rsync
* service-agent
* sign-url - gcloud survey
- gcloud tasks
- gcloud telco-automation
- gcloud topic
- gcloud transcoder
- gcloud transfer
- gcloud vector-search
- gcloud version
- gcloud vmware
- gcloud workbench
- gcloud workflows
- gcloud workload-identity
- gcloud workspace-add-ons
- gcloud workstations
gcloud storage rm
NAME
gcloud storage rm - delete objects and buckets
SYNOPSIS
gcloud storage rm [[URLS](#URLS) …] [[--additional-headers](#--additional-headers)=HEADER=VALUE] [[--all-versions](#--all-versions), [-a](#-a)] [[--continue-on-error](#--continue-on-error), [-c](#-c)] [[--exclude-managed-folders](#--exclude-managed-folders)] [[--read-paths-from-stdin](#--read-paths-from-stdin), -I] [[--recursive](#--recursive), -R, [-r](#-r)] [[--if-generation-match](#--if-generation-match)=GENERATION [--if-metageneration-match](#--if-metageneration-match)=METAGENERATION] [[GCLOUD_WIDE_FLAG](#GCLOUD-WIDE-FLAGS) …]
DESCRIPTION
Delete objects and buckets.
EXAMPLES
The following command deletes a Cloud Storage object named`my-object` from the bucket`my-bucket`:
gcloud storage rm gs://my-bucket/my-objectThe following command deletes all objects directly within the directory`my-dir` but no objects within subdirectories:
gcloud storage rm gs://my-bucket/my-dir/*The following command deletes all objects and subdirectories within the directory `my-dir`:
gcloud storage rm gs://my-bucket/my-dir/**Note that for buckets that contain versioned objects, the above command only affects live versions. Use the--recursive flag instead to delete all versions.
The following command deletes all versions of all resources in`my-bucket` and then deletes the bucket.
gcloud storage rm --recursive gs://my-bucket/The following command deletes all text files in the top-level of`my-bucket`, but not text files in subdirectories:
gcloud storage rm -recursive gs://my-bucket/*.txtThe following command deletes one wildcard expression per line passed in by stdin:
some_program | gcloud storage rm -IPOSITIONAL ARGUMENTS
[URLS …]
The URLs of the resources to delete.
FLAGS
Includes arbitrary headers in storage API calls. Accepts a comma separated list of key=value pairs, e.g. header1=value1,header2=value2. Overrides the default storage/additional_headers property value for this command invocation.
--all-versions, -a
Delete all versions of an object.
--continue-on-error, -c
If any operations are unsuccessful, the command will exit with a non-zero exit status after completing the remaining operations. This flag takes effect only in sequential execution mode (i.e. processor and thread count are set to 1). Parallelism is default.
--exclude-managed-folders
Excludes managed folders from command operations. By default gcloud storage includes managed folders in recursive removals. Please note that this flag would not be applicable for hierarchical namespace buckets as we always list managed folders for these buckets.
--read-paths-from-stdin, -I
Read the list of URLs from stdin.
--recursive, -R, -r
Recursively delete the contents of buckets or directories that match the path expression. By default, this will delete managed folders as well. If the path is set to a bucket, like `gs://bucket`, the bucket is also deleted. This option implies the --all-versionsoption. If you want to delete only live object versions, use the ``**´´ wildcard instead.
PRECONDITION FLAGS
--if-generation-match=GENERATION
Execute only if the generation matches the generation of the requested object.
--if-metageneration-match=METAGENERATION
Execute only if the metageneration matches the metageneration of the requested object.
GCLOUD WIDE FLAGS
These flags are available to all commands: [--access-token-file](/sdk/gcloud/reference#--access-token-file),[--account](/sdk/gcloud/reference#--account), [--billing-project](/sdk/gcloud/reference#--billing-project),[--configuration](/sdk/gcloud/reference#--configuration),[--flags-file](/sdk/gcloud/reference#--flags-file),[--flatten](/sdk/gcloud/reference#--flatten), [--format](/sdk/gcloud/reference#--format), [--help](/sdk/gcloud/reference#--help), [--impersonate-service-account](/sdk/gcloud/reference#--impersonate-service-account),[--log-http](/sdk/gcloud/reference#--log-http),[--project](/sdk/gcloud/reference#--project), [--quiet](/sdk/gcloud/reference#--quiet), [--trace-token](/sdk/gcloud/reference#--trace-token), [--user-output-enabled](/sdk/gcloud/reference#--user-output-enabled),[--verbosity](/sdk/gcloud/reference#--verbosity).
Run $ [gcloud help](/sdk/gcloud/reference) for details.
NOTES
This variant is also available:
gcloud alpha storage rmExcept as otherwise noted, the content of this page is licensed under the Creative Commons Attribution 4.0 License, and code samples are licensed under the Apache 2.0 License. For details, see the Google Developers Site Policies. Java is a registered trademark of Oracle and/or its affiliates.
Last updated 2026-05-27 UTC.