- NAME
-
- gcloud storage rm - delete objects and buckets
- SYNOPSIS
-
-
gcloud storage rm
[URLS
…] [--additional-headers
=HEADER
=VALUE
] [--all-versions
,-a
] [--continue-on-error
,-c
] [--exclude-managed-folders
] [--read-paths-from-stdin
,-I
] [--recursive
,-R
,-r
] [--if-generation-match
=GENERATION
--if-metageneration-match
=METAGENERATION
] [GCLOUD_WIDE_FLAG …
]
-
- DESCRIPTION
- Delete objects and buckets.
- EXAMPLES
-
The following command deletes a Cloud Storage object named
from the bucketmy-object
:my-bucket
gcloud storage rm gs://my-bucket/my-object
The following command deletes all objects directly within the directory
but no objects within subdirectories:my-dir
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
and then deletes the bucket.my-bucket
gcloud storage rm --recursive gs://my-bucket/
The following command deletes all text files in the top-level of
, but not text files in subdirectories:my-bucket
gcloud storage rm -recursive gs://my-bucket/*.txt
The following command deletes one wildcard expression per line passed in by stdin:
some_program | gcloud storage rm -I
- POSITIONAL ARGUMENTS
-
- [
URLS
…] - The URLs of the resources to delete.
- [
- FLAGS
-
--additional-headers
=HEADER
=VALUE
-
Includes arbitrary headers in storage API calls. Accepts a comma separated list
of key=value pairs, e.g.
header1=value1,header2=value2
. Overrides the defaultstorage/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. If the path is set to a bucket, like
, the bucket is also deleted. This option implies thegs://bucket
--all-versions
option. 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
,--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:
gcloud alpha storage rm
Except 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 2024-07-02 UTC.