Predictive Hacks

AWS S3 CLI ls in a Human Readable Format

AWS CLI allows us to interact with the AWS from the command line, known also as terminal. A very common command is the:

aws s3 ls s3://my-bucket/my-path/

where the output is like:

2021-11-18 15:55:20   29161259 file_01.csv
2021-11-18 15:55:21   29137661 file_02.csv
2021-11-18 15:55:21   29154017 file_03.csv
2021-11-18 15:55:20   29160631 file_04.csv
2021-11-18 15:55:20   29148803 file_05.csv
2021-11-18 15:55:20   29155569 file_06.csv
2021-11-18 15:55:20   29169410 file_07.csv
2021-11-18 15:55:20   29152556 file_08.csv

As we can see, the size of the files is in bytes. If we want the output to be in a “human-readable format” and also to have a summary of the folder we can add the following flags to the ls command:

aws s3 ls s3://my-bucket/my-path/ --human-readable --summarize

And we get:

2021-11-18 15:55:20   27.8 MiB file_01.csv
2021-11-18 15:55:21   27.8 MiB file_02.csv
2021-11-18 15:55:21   27.8 MiB file_03.csv
2021-11-18 15:55:20   27.8 MiB file_04.csv
2021-11-18 15:55:20   27.8 MiB file_05.csv
2021-11-18 15:55:20   27.8 MiB file_06.csv
2021-11-18 15:55:20   27.8 MiB file_07.csv
2021-11-18 15:55:20   27.8 MiB file_08.csv

Total Objects: 8
   Total Size: 222.4 MiB

Finally, if you want to see the size of all folders and subfolder in a human readable format, you can add the –recursive flag. For example:

aws s3 ls s3://my-bucket/ --human-readable --summarize --recursive

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


Image Captioning with HuggingFace

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


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