Search code examples
amazon-web-servicesamazon-s3aws-cli

How can I use wildcards to `cp` a group of files with the AWS CLI?


I'm having trouble using * in the AWS CLI to select a subset of files from a certain bucket.

Adding * to the path like this does not seem to work:

aws s3 cp s3://data/2016-08* .


Solution

  • To download multiple files from an Amazon AWS bucket to your current directory, you can use the recursive, exclude, and include flags. The order of the parameters matters.

    Example command:

    aws s3 cp s3://data/ . --recursive --exclude "*" --include "2016-08*"
    

    For more information on how to use these filters: Use of Exclude and Include Filters