r0f1
r0f1

Reputation: 3106

gsutil - Find Files and Folders

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.

Upvotes: 8

Views: 17463

Answers (2)

A. Askarov
A. Askarov

Reputation: 715

Since gsutil tool is now obsolete, here is the new command

gcloud storage ls gs://[BUCKET_NAME]/** | grep {str or regex}

note: my shell asks to escape * (star) character so for me it is

gcloud storage ls gs://[BUCKET_NAME]/\*\* | grep {str or regex}

Upvotes: 2

Juliusz Abramczyk
Juliusz Abramczyk

Reputation: 131

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.

Upvotes: 13

Related Questions