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.