5

Is there a find or grep-like command that I can use to search my Google Buckets?

I can only find ls, but it is not quite what I need. I want to search for specific folder names and file names, that contain a certain string or match a certain regex.

r0f1
  • 2,717
  • 3
  • 26
  • 39
  • 3
    The closest to a command to search is `gsutil ls -r gs://[BUCKET_NAME]/[PREFIX]**` wich will let you search objects by a certain prefix. Otherwise you can elaborate a script to find specific names or prefix using as example this [Listing objects](https://cloud.google.com/storage/docs/listing-objects#storage-list-objects-python) documentation. – Chris32 Sep 04 '19 at 11:46

1 Answers1

8

You can use your system grep:

gsutil ls gs://[BUCKET_NAME]/** | grep {string or regexp}

No need to use -r as ** already flattens the folder structure.

  • 2
    Also useful: `gsutil ls gs://[BUCKET_NAME]/**/[FILE_NAME]` – Jonas Beck Oct 21 '20 at 16:26
  • @JonasBeck indeed it is - **however**, using simply the prefix followed by `grep` was significantly faster. I guess their server-side regex parsing lib is slower than `grep`'s – Guy Jun 01 '22 at 14:36