Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

gsutil returning "no matches found"

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?

like image 393
JohnGB Avatar asked Aug 22 '16 08:08

JohnGB


People also ask

How do I run a gsutil command in Python?

gsutil cp gs://my-gsutil-bucket-12005/test-renamed.txt . Copy a file from a bucket to your local computer with Python: Note that unlike with gsutil , with Python, you must specify a valid path for the local file name to store the remote object. If you specify dot as with gsutil , an error would occur.

Is gsutil CP Secure?

gsutil performs all operations using transport-layer encryption (HTTPS), to protect against data leakage over shared network links.


1 Answers

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.

like image 52
Mike Schwartz Avatar answered Sep 21 '22 13:09

Mike Schwartz