Forrest logo
back to the gsutil tool

gsutil:tldr:e16c8

gsutil: List the objects in a bucket.
$ gsutil ls -r 'gs://${bucket_name}/${prefix}**'
try on your machine

The command gsutil ls -r 'gs://${bucket_name}/${prefix}**' is used to list the objects in a Google Cloud Storage (GCS) bucket recursively. Here's an explanation of the different parts of the command:

  • gsutil: It is a command-line tool provided by Google Cloud SDK for interacting with Google Cloud Storage.
  • ls: It is a command used to list objects in a GCS bucket.
  • -r: It stands for "recursive" and is used to include all objects in subdirectories of the specified prefix.
  • 'gs://${bucket_name}/${prefix}**': This is the path to the bucket and objects you want to list. It consists of two parts:
    • ${bucket_name}: It is a placeholder that should be replaced with the name of your GCS bucket.
    • ${prefix}: It is a placeholder that should be replaced with the prefix or directory path inside the bucket that you want to list objects from.

By using ** after ${prefix}, it includes all objects in subdirectories under the specified prefix. The gs:// prefix before ${bucket_name} indicates that it is a GCS bucket.

This explanation was created by an AI. In most cases those are correct. But please always be careful and never run a command you are not sure if it is safe.
back to the gsutil tool