gsutil returning “no matches found”

2020-07-01 02:28发布

I'm trying using gsutil to remove the contents of a Cloud Storage bucket (but not the bucket itself). According to the documentation, the command should be:

gsutil rm gs://bucket/**

However, whenever I run that (with my bucket name substituted of course), I get the following response:

zsh: no matches found: gs://my-bucket/**

I've checked permissions, and I have owner permissions. Additionally, if I specify a file, which is in the bucket, directly, it is successfully deleted.

Other information which may matter:

  • My bucket name has a "-" in it (similar to "my-bucket")
  • It is the bucket that Cloud Storage saves my usage logs to

How do I go about deleting the contents of a bucket?

2条回答
smile是对你的礼貌
2楼-- · 2020-07-01 02:46
gsutil rm  gs://bucketName/doc.txt

And for remove entire bucket including all objects

gsutil rm -r gs://bucketname
查看更多
乱世女痞
3楼-- · 2020-07-01 02:48

zsh is attempting to expand the wildcard before gsutil sees it (and is complaining that you have no local files matching that wildcard). Please try this, to prevent zsh from doing so:

gsutil rm 'gs://bucket/**'

Note that you need to use single (not double) quotes to prevent zsh wildcard handling.

查看更多
登录 后发表回答