This guide will explain how to use wildcards to “cp” a group file with AWS CLI.
How Can I Use Wildcards to `cp` a Group of Files With AWS CLI?
Open the “Terminal” from the local system:
Check whether the AWS CLI is installed on the system by using the following command:
Executing the above command displays the “aws-cli/2.11.0” installed version of AWS CLI:
Configure the AWS using the IAM credentials:
Click here to learn how to configure AWS CLI.
Locate the directory in which the group of files is placed from the local computer:
Head into the folder and find a group of files:
Use the following AWS CLI command to upload the files on the S3 bucket:
The above command copies the files from the local directory and uploads them to the S3 bucket. The wildcard here is that it does not copy the “myapp.html” file:
Visit the S3 dashboard and click on the “Buckets” page:
Click on the bucket name to open it:
Head inside the “prefix/” folder:
All the files have been copied to the S3 bucket except “myapp.html” which was excluded using a wildcard:
Head back to the buckets page and click on the “Empty” button:
Type “permanently delete” to confirm the deletion of all the objects and then click on the “Empty” button:
After emptying the bucket, click on the “Exit” button:
Use the following command to use the include wildcard:
The above command has excluded everything by adding a “*” to it and just including only “myapp.html” file:
The bucket only contains the “myapp.html” file and others files have been excluded:
This guide has explained how to use wildcards to ‘cp’ a group of files with AWS CLI.
Conclusion
To use wildcards to copy a group of files with AWS CLI, it is required to install AWS CLI and then configure it using the IAM credentials. Locate the directory from the local system from where the files will be copied and pasted to the AWS cloud. Use the AWS CLI with wildcards to exclude or include the selected files from the pile. This guide has explained how to use wildcards to ‘cp’ a group of files with AWS CLI.