stat - Display object status
Synopsis
gsutil stat url...
Description
The stat command will output details about the specified object URLs. It is similar to running:
gsutil ls -L gs://some-bucket/some-object
but is more efficient because it avoids performing bucket listings gets the minimum necessary amount of object metadata.
The gsutil stat command will, however, perform bucket listings if you specify URLs using wildcards.
If run with the gsutil -q option nothing will be printed, e.g.:
gsutil -q stat gs://some-bucket/some-object
This can be useful for writing scripts, because the exit status will be 0 for an existing object and 1 for a non-existent object.
Note: Unlike the gsutil ls command, the stat command does not support operations on sub-directories. For example, if you run the command:
gsutil -q stat gs://some-bucket/some-object/
gsutil will look up information about the object “some-object/” (with a trailing slash) inside bucket “some-bucket”, as opposed to operating on objects nested under gs://some-bucket/some-object. Unless you actually have an object with that name, the operation will fail.