gsutil ls --help

From wikieduonline
Jump to navigation Jump to search

gsutil ls --help
NAME
 ls - List providers, buckets, or objects


SYNOPSIS

 gsutil ls [-a] [-b] [-d] [-l] [-L] [-r] [-p proj_id] url...


DESCRIPTION
Retrieves a list of providers, buckets, or objects matching the criteria,
ordered in the list lexicographically by name.
 
LISTING PROVIDERS, BUCKETS, SUBDIRECTORIES, AND OBJECTS
 If you run ``gsutil ls`` without URLs, it lists all of the Google Cloud Storage
 buckets under your default project ID (or all of the Cloud Storage buckets
 under the project you specify with the ``-p`` flag):

   gsutil ls

 If you specify one or more provider URLs, ``gsutil ls`` lists buckets at each
 listed provider:

   gsutil ls gs://

 gsutil currently supports ``gs://`` and ``s3://`` as valid providers
 
  If you specify bucket URLs, or use `Wildcards
  <https://cloud.google.com/storage/docs/gsutil/addlhelp/WildcardNames>`_ to
  capture a set of buckets, ``gsutil ls`` lists objects at the top level of each
  bucket, along with the names of each subdirectory. For example:

    gsutil ls gs://bucket

  might produce output like:

    gs://bucket/obj1.htm
    gs://bucket/obj2.htm
    gs://bucket/images1/
    gs://bucket/images2/

  The "/" at the end of the last 2 URLs tells you they are subdirectories,
  which you can list using:

    gsutil ls gs://bucket/images*

  If you specify object URLs, ``gsutil ls`` lists the specified objects. For
  example:

    gsutil ls gs://bucket/*.txt

  lists all files whose name matches the above wildcard at the top level of
  the bucket.

  See "gsutil help wildcards" for more details on working with wildcards.


DIRECTORY BY DIRECTORY, FLAT, and RECURSIVE LISTINGS
  Listing a bucket or subdirectory (as illustrated near the end of the previous
  section) only shows the objects and names of subdirectories it contains. You
  can list all objects in a bucket by using the -r option. For example:

    gsutil ls -r gs://bucket

  lists the top-level objects and buckets, then the objects and buckets under
  gs://bucket/images1, then those under gs://bucket/images2, etc.

  If you want to see all objects in the bucket in one "flat" listing use the
  recursive ("**") wildcard, like:

    gsutil ls -r gs://bucket/**

  or, for a flat listing of a subdirectory:

    gsutil ls -r gs://bucket/dir/**

  If you want to see only the subdirectory itself, use the -d option:

    gsutil ls -d gs://bucket/dir


LISTING OBJECT DETAILS
  If you specify the -l option, gsutil outputs additional information about
  each matching provider, bucket, subdirectory, or object. For example:

    gsutil ls -l gs://bucket/*.html gs://bucket/*.txt

  prints the object size, creation time stamp, and name of each matching
  object, along with the total count and sum of sizes of all matching objects:

       2276224  2020-03-02T19:25:17Z  gs://bucket/obj1.html
       3914624  2020-03-02T19:30:27Z  gs://bucket/obj2.html
           131  2020-03-02T19:37:45Z  gs://bucket/obj3.txt
    TOTAL: 3 objects, 6190979 bytes (5.9 MiB)

  Note that the total listed in parentheses above is in mebibytes (or gibibytes,
  tebibytes, etc.), which corresponds to the unit of billing measurement for
  Google Cloud Storage.

  You can get a listing of all the objects in the top-level bucket directory
  (along with the total count and sum of sizes) using a command like:

    gsutil ls -l gs://bucket

  To print additional detail about objects and buckets use the gsutil ls -L
  option. For example:

    gsutil ls -L gs://bucket/obj1

  prints something like:

    gs://bucket/obj1:
            Creation time:                    Fri, 26 May 2017 22:55:44 GMT
            Update time:                      Tue, 18 Jul 2017 12:31:18 GMT
            Storage class:                    STANDARD
            Content-Length:                   60183
            Content-Type:                     image/jpeg
            Hash (crc32c):                    zlUhtg==
            Hash (md5):                       Bv86IAzFzrD1Z2io/c7yqA==
            ETag:                             5ca67960a586723b7344afffc81
            Generation:                       1378862725952000
            Metageneration:                   1
            ACL:                              [
      {
        "entity": "project-owners-867484910061",
        "projectTeam": {
          "projectNumber": "867484910061",
          "team": "owners"
        },
        "role": "OWNER"
      },
      {
        "email": "[email protected]",
        "entity": "[email protected]",
        "role": "OWNER"
      }
    ]
    TOTAL: 1 objects, 60183 bytes (58.77 KiB)

  Note that results may contain additional fields, such as custom metadata or
  a storage class update time, if they are applicable to the object.

  Also note that some fields, such as update time, are not available with the
  (non-default) XML API.

  See also "gsutil help acl" for getting a more readable version of the ACL.


LISTING BUCKET DETAILS
  If you want to see information about the bucket itself, use the -b
  option. For example:

    gsutil ls -L -b gs://bucket

  prints something like:

    gs://bucket/ :
            Storage class:                STANDARD
            Location constraint:          US
            Versioning enabled:           False
            Logging configuration:        None
            Website configuration:        None
            CORS configuration:           None
            Lifecycle configuration:      None
            Requester Pays enabled:       True
            Labels:                       None
            Default KMS key:              None
            Time created:                 Thu, 14 Jan 2016 19:25:17 GMT
            Time updated:                 Thu, 08 Jun 2017 21:17:59 GMT
            Metageneration:               1
            Bucket Policy Only enabled:   False
            ACL:
              [
                {
                  "entity": "project-owners-867489160491",
                  "projectTeam": {
                    "projectNumber": "867489160491",
                    "team": "owners"
                  },
                  "role": "OWNER"
                }
              ]
            Default ACL:
              [
                {
                  "entity": "project-owners-867489160491",
                  "projectTeam": {
                    "projectNumber": "867489160491",
                    "team": "owners"
                  },
                  "role": "OWNER"
                }
              ]

  Note that some fields above (time created, time updated, metageneration) are
  not available with the (non-default) XML API.


OPTIONS
  -l          Prints long listing (owner, length).

  -L          Prints even more detail than -l.

              Note: If you use this option with the (non-default) XML API it
              generates an additional request per object being listed, which
              makes the -L option run much more slowly and cost more than the
              default JSON API.

  -d          List matching subdirectory names instead of contents, and do not
              recurse into matching subdirectories even if the -R option is
              specified.

  -b          Prints info about the bucket when used with a bucket URL.

  -h          When used with -l, prints object sizes in human readable format
              (e.g., 1 KiB, 234 MiB, 2 GiB, etc.)

  -p proj_id  Specifies the project ID or project number to use for listing
              buckets.

  -R, -r      Requests a recursive listing, performing at least one listing
              operation per subdirectory. If you have a large number of
              subdirectories and do not require recursive-style output ordering,
              you may be able to instead use wildcards to perform a flat
              listing, e.g.  ``gsutil ls gs://mybucket/**``, which generally
              performs fewer listing operations.

  -a          Includes non-current object versions / generations in the listing
              (only useful with a versioning-enabled bucket). If combined with
              -l option also prints metageneration for each listed object.

  -e          Include ETag in long listing (-l) output.



See also[edit]

* gsutil ls, gsutil ls -L, * gsutil [ config | singurl | mb | iam | cp | ls | acl | defacl | ubla | du | cors | --help], $HOME/.boto, Cloud Shell

Advertising: