Copy folders from S3 bucket with specific prefix

Viewed 787

I have an S3 bucket

aws s3 ls s3://myBucket/
                           PRE 2020032600/
                           PRE 2020032700/
                           PRE 2020032800/
                           PRE results_2020011200/
                           PRE results_2020011300/
                           PRE results_2020011400/
                           PRE results_2020011500/

I want to copy locally only the folders that start with results_

aws s3 cp s3://myBucket/*something /Users/myName/myFolder/ --recursive
1 Answers

You can use the include and exclude arguments,

aws s3 cp s3://myBucket/ /Users/myName/myFolder/ --recursive --exclude "*" --include "results_*"

All files will be excluded from the bucket except for files starting with results_. The order of the exclude and include arguments is important.

Related