How to select a file from aws s3 by using wild character

user3858193 picture user3858193 · Apr 10, 2015 · Viewed 21.3k times · Source

I have many a files in s3 bucket and I want to copy those files which have start date of 2012. This below command copies all the file.

aws s3 cp s3://bp-dev/bp_source_input/ C:\Business_Panorama\nts\data\in --recursive  --include "201502_nts_*.xlsx"

Answer

bsnchan picture bsnchan · Apr 10, 2015

You may want to add the "--exclude" flag before your include filter.

The AWS CLI takes the filter "--include" to include it in your already existing search. Since all the files are being returned, you need to exclude all the files first, before including the 2015*.xlsx.

If you want files with only the format "201502_nts_*.xlsx", you can run aws s3 cp s3://bp-dev/bp_source_input/ C:\Business_Panorama\nts\data\in --recursive --exclude * --include "201502_nts_*.xlsx"