英文:
How to delete specific sub directory with wildcard gsutil?
问题
受这个问题的启发,我正在尝试使用gsutil
命令中的通配符来删除存储桶中的特定文件夹,例如:
gsutil rm -r gs://bucket-name/path/to/**/content
或者
gsutil rm -r gs://bucket-name/path/to/*/content
这会引发以下错误:
zsh: no matches found: gs://bucket-name/path/to/**/content
zsh: no matches found: gs://bucket-name/path/to/*/content
其中的 *
或 **
用来替代ID(成千上万的记录),每个ID下都有2个目录:content
和content2
,我只想删除content
目录。
提前感谢您的帮助。
英文:
Inspired by this question i am trying to delete specific folders from my bucket using wildcard in a gsutil
command such as :
gsutil rm -r gs://bucket-name/path/to/**/content
or
gsutil rm -r gs://bucket-name/path/to/*/content
This is throwing the error :
zsh: no matches found: gs://bucket-name/path/to/**/content
zsh: no matches found: gs://bucket-name/path/to/*/content
Where the *
or **
is replacing IDs (thousands of records) and under each there are 2 directories : content
, content2
and i only want to remove the content
directory
Thanks in advance
答案1
得分: 2
按照Mike Schwartz的这个回答,在使用通配符时,您必须使用单引号或双引号。
zsh在
gsutil
看到通配符之前尝试展开它(并抱怨您没有本地文件与该通配符匹配)。请尝试以下方式,以防止zsh这样做:
gsutil rm 'gs://bucket/**'
英文:
As per this answer by @Mike Schwartz, You have to use single or double quotes while using wildcards.
> 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/**'
>
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论