【问题标题】:best way to download from a list of cloud storage buckets从云存储桶列表下载的最佳方式
【发布时间】:2021-07-10 19:26:15
【问题描述】:

除了这样做之外,从云存储桶列表中下载的最佳方法是什么:

gsutil cp gs://path1 .
gsutil cp gs://path2 .
gsutil cp gs://path3 .
...
gsutil cp gs://path1000 .

理想情况下还可以捕获错误消息

我试过了

for i in [gs://path1 gs://path2 ..]
  do gsutil cp $i .
done 

但这没有用。

【问题讨论】:

  • 您能否详细说明什么不起作用?是路径被折叠(将所有文件放到一个下载目录中),还是您没有获得足够的错误详细信息,或者花费的时间太长,或者...?
  • 它只显示“错误模式:[gs://path1”,并且没有通过循环下载任何内容。如果我在 gs//:path1 等周围添加引号,则错误消息是相同的。

标签: google-cloud-storage gsutil


【解决方案1】:

这是 linux for 循环错字。不用 []

也一样
for i in gs://path1 gs://path2 ..
  do gsutil cp $i .
done 

【讨论】:

  • 如果我需要从这样的文本文件中读取这个长列表:while read -r line;做 gsutil cp $line 。 done
  • 如果你每行有 1 个路径,或者每个路径用空格分隔,我建议你使用 cat 这样for i in $(cat myFile); do ...; done
猜你喜欢
  • 1970-01-01
  • 2017-06-11
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2019-04-13
  • 1970-01-01
  • 2011-12-15
  • 2019-11-04
相关资源
最近更新 更多