porton
porton

Reputation: 5801

gsutil: List only directories (bug?)

$ gsutil ls -d 'gs://XXX/test/**/' 
gs://XXX/test/
gs://XXX/test/336x280.swf.gz

So it lists not only directories (ending with /) but also regular files (ending with .gz for instance).

But accordingly my understanding this command should list only directories. Where is the error?

$ gsutil --version
gsutil version: 4.27

Or is it a gsutil bug?

Upvotes: 3

Views: 587

Answers (1)

mhouglum
mhouglum

Reputation: 2593

That's certainly a bug with gsutil. Would you mind opening up an issue on GitHub? https://github.com/GoogleCloudPlatform/gsutil/issues

In the mean time, a valid workaround would be piping the output to grep and checking for lines that end in /, e.g.:

gsutil ls -d <pattern> | grep "/$"

Upvotes: 1

Related Questions