AWS S3 cp WildCard
How to use AWS s3 cp using wildcard?
![]() |
| AWS S3 cp Wildcard |
The AWS S3 cp command is a command-line tool that allows you to copy files and folders to and from an Amazon S3 bucket. The "wildcard" feature is a feature of the S3 cp command that allows you to specify a pattern of files to be copied using wildcard characters.
Wildcards supported by AWS S3 cp command:
The AWS S3 cp command supports two wildcard characters: "" and "?". The "" wildcard matches zero or more characters, while the "?" wildcard matches exactly one character.
Using wildcards with the AWS S3 cp command:
You can use wildcards with the AWS S3 cp command to specify a pattern of files to be copied. For example, you can use the "*" wildcard to copy all files in a folder or use the "?" wildcard to copy a file with a specific character in its name
With the "wildcard" feature, you can copy multiple files that match a specific pattern in a single command. For example, you can use the "*" wildcard character to copy all files in a specific folder or use the "?" wildcard character to copy a file with a specific character in its name.
Here's an example command that uses the wildcard feature to copy all the files that start with "my" and have a ".txt" extension from a local folder to an S3 bucket:
aws s3 cp /path/to/local/folder s3://my-bucket/path/ --recursive --exclude "*" --include "my*.txt"
In this example, the "--exclude" parameter is used to exclude all files from the copy operation, and the "--include" parameter is used to include only the files that match the pattern "my*.txt". The "--recursive" parameter is used to copy all files in the subdirectories of the local folder.
To copy all files in a folder, use the following command:
aws s3 cp /path/to/local/folder s3://my-bucket/path/ --recursive --exclude "*" --include "*"
To copy a single file with a specific character in its name, use the following command:
aws s3 cp /path/to/local/folder/file?.txt s3://my-bucket/path/
In this example, the command will copy the file with the name "fileX.txt", where "X" is any single character.
Here are some reference links related to the AWS S3 cp command and its wildcard feature:
