Ritu Singh
You can use Wildcards in the AWS CLI commands as the special characters which enable you to create specific patterns in the commands. For example, the cp command is used to copy files from the clouds to the directory and vice-versa.
In this article, we have explained how you can use wildcards to a group of files i.e., cp with AWS CLI. So without further delay, let’s get into the topic.
How can you use the Wildcards to ‘cp’ a File Group with AWS CLI?
The following steps will help you understand the process.
Step 1:
Start a local system and open a ‘Terminal.’
Source: >LinuxHint
Step 2:
Cross-check whether you have installed AWS CLI on your system by using the below command:
After running the above command, it will display ‘aws-cli/2.11.0’ which is a AWS CLI installed version.
Source: >LinuxHint
Step 3:
Use IAM credentials and configure the AWS
Source: >LinuxHint
Step 4:
Identify the directory in which the group of files is stored
Source: >LinuxHint
Navigate to the folder and search for a group of files
Source: >LinuxHint
Step 5:
Now, use the below command for AWS CLI for uploading files on the S3 bucket
The aforementioned command from the local directory copies all the files and uploads them to the S3 bucket. The wildcard used here will not copy the myapp.html file:
Source: >LinuxHint
Step 6:
Navigate to the S3 dashboard and press on the ‘Buckets’ page
Source: >LinuxHint
Press on the bucket list and open the list:
Go to the ‘prefix/’ folder:
Source: >LinuxHint
You can see that all the files are copied to the S3 bucket excluding myapp.html which is not included in the wildcard:
Source: >LinuxHint
Navigate back to the buckets page and press on the Empty button:
Source: >LinuxHint
Write ‘permanently delete’ and then press on the ‘Empty’ button.
Source: >LinuxHint
Now, click on the ‘Exit’ button.
Step 7:
The below command will help you to use the wildcards that are included:
By appending a "*" to the command above, everything was omitted, and only the "myapp.html" file was included:
Source: >LinuxHint
Only the "myapp.html" file is present in the bucket; other files have been left out.
Source: >LinuxHint