USING UNIX WILDCARDS WITH AWS S3 (AWS CLI)
The AWS command line interface does not currently support UNIX wildcard support in the command path argument. However, it is fairly easy to reproduce this function using the --exclude and --include options, available in several aws s3 commands.
Wildcards available for use:
"*" - matches everything
"?" - Matches any single character
"[]" - matches any single character in brackets
"[!]" - matches any single character not enclosed in brackets
A few things to keep in mind when using --include and --exclude with the aws s3 command:
You can use any number of --include and --exclude options .
Parameters passed later take precedence over parameters passed earlier (in the same command).
All files and objects are enabled by default on ', so to include only certain files you need to use "exclude" and then "include". --recursive should be used together with --include and --exclude , otherwise the commands will only perform operations on one file / object.
Examples: Copy all files from the working directory to the big data dumpster:
aws s3 cp ./ s3://big-datums/ --recursive
Delete all .java files from the big data dumpster:
aws s3 rm s3://big-datums/ --recursive --exclude "*" --include "*.java"
Delete all files in the big data area with the file extension with "j" or "c" (".csv", ".java,". Json ",." Jpeg ", etc.):
aws s3 rm s3://big-datums/ --recursive --exclude "*" --include "*.[jc]*"
Copy the ".txt" and ".csv" files from the large S3 database to the local working directory:
aws s3 cp s3://big-datums/ . --recursive --exclude "*" --include "*.txt" --include "*.csv"
#Copy all files from working directory to the big-datums bucket: aws s3 cp ./ s3://big-datums/ --recursive #Delete all ".java" files from the big-datums bucket: aws s3 rm s3://big-datums/ --recursive --exclude "*" --include "*.java" #Delete all files in the big-datums bucket with a file extension beginning with "j" or "c" (".csv", ".java, ".json", ."jpeg", etc.): aws s3 rm s3://big-datums/ --recursive --exclude "*" --include "*.[jc]*" #Copy ".txt" and ".csv" files from big-datums S3 bucket to local working directory: aws s3 cp s3://big-datums/ . --recursive --exclude "*" --include "*.txt" --include "*.csv" '''