Google Certified Associate Cloud Engineer 2020

Sign Up Free or Log In to participate!

what is the difference between the out from running these command- gsutil list gs:///* and gsutil list gs:///**

Indradip Halder

@cloudshell:~ (service-labs-257802)$ gsutil list gs://first-storage-bucket/*

gs://first-storage-bucket/AT1-An-anatomy-of-a-cyber-attack.drawio-6-2-4-2.xml

gs://first-storage-bucket/test/:

gs://first-storage-bucket/test/

gs://first-storage-bucket/test/AT1-An-anatomy-of-a-cyber-attack.drawio-6-2-4.jpg

@cloudshell:~ (service-labs-257802)$ gsutil list gs://first-storage-bucket/**

gs://first-storage-bucket/AT1-An-anatomy-of-a-cyber-attack.drawio-6-2-4-2.xml

gs://first-storage-bucket/test/

gs://first-storage-bucket/test/AT1-An-anatomy-of-a-cyber-attack.drawio-6-2-4.jpg

*@cloudshell:~ (service-labs-257802)$

1 Answers

Mattias Andersson

Hello!  Good on you for trying things out and trying to make sense of it.

In this case, I think what’s going on is that * is telling gsutil to do a list (ls) on each of the objects that match that level of the hierarchy–and since one of them is a folder (it ends with a slash), it lists its contents.  But try out putting in another level of hierarchy–does it show the contents of that level, too?

On the other hand, ** tells gsutil to show all of the objects under that folder but in a "flat" way–not showing all of the directory structure.  And passing -r tells it to keep recursing into all subfolders.

Check out this gsutil ls documentation page for all the details. 🙂

Mattias

Sign In
Welcome Back!

Psst…this one if you’ve been moved to ACG!

Get Started
Who’s going to be learning?