我正在使用swift CLI并尝试从容器中下载多个对象。
我可以这样做
for i in `swift list container -p object/201505`; do swift download container $i; done
问题是我需要搜索多个对象并下载所有匹配项。我试过用一个小脚本来做。
#!/bin/bash
while read objects;
SAMPLE=$(swift list container objects);
do
for i in $SAMPLE; do `swift download container $i`; done
done < samples_list
但我总是受到以下欢迎。
Usage: swift [options] list [options] [container]
Lists the containers for the account or the objects for a container. -p or
--prefix is an option that will only list items beginning with that prefix.
-d or --delimiter is option (for container listings only) that will roll up
items with the given delimiter (see Cloud Files general documentation for
what this means).
我的变量没有被阅读?如何只下载我设置的正确前缀的文件?
答案 0 :(得分:1)
我真的不知道swift
,但我认为你想要
#!/bin/bash
while read objects; do
swift list container "$objects" | while read i; do
swift download container "$i"
done
done < samples_list
我假设swift list
在其输出中每行写一个项目。