Intellipaat Back

Explore Courses Blog Tutorials Interview Questions
0 votes
2 views
in AWS by (19.1k points)

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 hundreds of files I need to download so that it seems not possible to use one single command that takes all filenames as arguments.

1 Answer

0 votes
by (44.4k points)

You can run a bash script like this, but you will have to have all the filenames in a file like filename.txt then use it download them.

#!/bin/bash  

set -e  

while read line  

do  

  aws s3 cp s3://bucket-name/$line dest-path/  

done <filename.txt

Related questions

Want to get 50% Hike on your Salary?

Learn how we helped 50,000+ professionals like you !

+1 vote
1 answer

31k questions

32.8k answers

501 comments

693 users

Browse Categories

...