One of the most fustrating things when using Google Cloud Storage is not being able to search files using wildcards: Google Cloud web interface only allows stating a file prefix, what in many cases is not enough.
Luckly, Google Cloud SDK
gsultil ls, also available throught the Google Cloud Console, allows listing storage bucket contents using wildcards. Let's see some examples:Listing all the available buckets
gsutil ls
Listing a specific bucket content
gsutil ls gs://my_bucket
Listing, in a specific bucket, all the files matching a classic wilcard pattern
As usual,
* symbol matches zero or more characters, ? symbol matches only one character.gsutil ls gs://my_bucket/foo*.json
gsutil ls gs://my_bucket/*bar.json
gsutil ls gs://my_bucket/foo*bar.json
gsutil ls gs://my_bucket/foo*.jso?
Listing, in a specific bucket, content matching advanced wilcard pattern
A set of characters into brackets matches all the filenames that has one of those characters. For instance f[eo] would match
fe and fo, but not feo.
gsutil ls gs://my_bucket/f[aeiou]o*.json
A range of characters into brackets matches all the filenames that has one of the characters in the range. For instance
f[e-o] would match fe, fi and fo, but again not feio. In that way, the previous example could be written as:
gsutil ls gs://my_bucket/f[a-u]o*.json

Comentarios
Publicar un comentario