stat - Display object status

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 and gets the minimum necessary amount of object metadata. Moreover, because it avoids performing bucket listings (which for some storage providers are eventually consistent) the gsutil stat command provides a strongly consistent way to check for the existence (and read the metadata) of an object.

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 behavior can be useful when writing scripts: even though nothing is printed from the command, it still has an exit status of 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-subdir/

gsutil will look for information about an object called "some-subdir/" (with a trailing slash) inside the bucket "some-bucket", as opposed to operating on objects nested under gs://some-bucket/some-subdir/. Unless you actually have an object with that name, the operation will fail. However, you can use the stat command on objects within subdirectories. For example, this command will work as expected:

gsutil -q stat gs://some-bucket/some-subdir/file.txt
이 페이지가 도움이 되었나요? 평가를 부탁드립니다.

다음에 대한 의견 보내기...

도움이 필요하시나요? 지원 페이지를 방문하세요.