Gsutil - How can I check if a file exists in a GCS bucket (a sub-directory) using Gsutil

activelearner picture activelearner · Mar 31, 2015 · Viewed 16k times · Source

I have a GCS bucket containing some files in the path

gs://main-bucket/sub-directory-bucket/object1.gz

I would like to programmatically check if the sub-directory bucket contains one specific file. I would like to do this using gsutil.

How could this be done?

Answer

jterrace picture jterrace · Mar 31, 2015

You can use the gsutil stat command.