Skip to content

Check whether a file exists or not in a Google Cloud Storage bucket using gsutil

The gsutil stat command provides a strongly consistent way to check for the existence (and read the metadata) of an object.

Use the following command:

gsutil -q stat gs://bucket/file

If this command returns 0 (false), the file does not exist at all.
If this command returns non-zero (true), the file already exists.

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.