Predictive Hacks

How to Check the Operation Before Running the AWS S3 CLI Command using dryrun

When you work with AWS S3 CLI and you run commands such as rm, I strongly suggest using the --dryrun flag:

  • --dryrun (boolean) Displays the operations that would be performed using the specified command without actually running them.

For example, let’s say that we want to remove the file_1.txt and file file_2.txt from the my-bucket/myfolder. Using the --dryrun flag, will receive a message of which files would have been removed if we had actually run the command

aws s3 rm s3://my-bucket/myfolder/ --dryrun --recursive --exclude "*" --include "file_1.txt" --include "file_2.txt"

Output:

(dryrun) delete: 3://my-bucket/myfolder/file_1.txt
(dryrun) delete: 3://my-bucket/myfolder/file_2.txt

NB: Keep in mind that the order of the filter options such as exclude and include plays a role. The filter options that appear later overwrite those that appear earlier. In our example, we excluded everything in the first place but then we included the two specific files. Since this can be tricky, before you run any kind of these commands, always use the --dryrun flag!

Better safe than sorry!

Share This Post

Share on facebook
Share on linkedin
Share on twitter
Share on email

Subscribe To Our Newsletter

Get updates and learn from the best

More To Explore

Python

Image Captioning with HuggingFace

Image captioning with AI is a fascinating application of artificial intelligence (AI) that involves generating textual descriptions for images automatically.

Python

Intro to Chatbots with HuggingFace

In this tutorial, we will show you how to use the Transformers library from HuggingFace to build chatbot pipelines. Let’s