amazon-web-servicesamazon-s3aws-cli

Copy multiple files from s3 bucket


I am having trouble downloading multiple files from AWS S3 buckets to my local machine.

I have all the filenames that I want to download and I do not want others. How can I do that ? Is there any kind of loop in aws-cli I can do some iteration ?

There are couple hundreds files I need to download so that it seems not possible to use one single command that takes all filenames as arguments.


Solution

  • There is a bash script which can read all the filenames from a file filename.txt.

    #!/bin/bash  
    set -e  
    while read line  
    do  
      aws s3 cp s3://bucket-name/$line dest-path/  
    done <filename.txt