1

I'm using swift CLI and trying to download multiple objects from a container.

I can do this as such

for i in `swift list container -p object/201505`; do swift download container $i; done

the problem is I have multiple objects I need to search for and download all that match. I've tried doing it in a small script.

#!/bin/bash

while read objects;
SAMPLE=$(swift list container objects);
do
for i in $SAMPLE; do `swift download container $i`; done
done < samples_list

But I am always greeted with the following.

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).

Are my variables not being read? How can I download only the files that have the correct prefix as I set?

1 Answers1

1

I don't really know swift, but I think you want

#!/bin/bash

while read objects; do
  swift list container "$objects" | while read i; do
    swift download container "$i"
  done
done < samples_list

I am assuming swift list writes one item per line in its output.

chepner
  • 497,756
  • 71
  • 530
  • 681
  • Dear sir, thank you for the fast response. I have edited the script to reflect your changes and it gives the same error. I'll do the needful and investigate more of it being openstack swift issue. – Ahmed Ramanesh Aug 10 '16 at 17:54