
Below are the list of AWS CLI 2 command options that you make use of with S3 ls command,
Example 1: To get a list of all S3 buckets in your AWS account,
% aws s3 ls
Output:
2022-08-16 10:44:36 my-code2care-bucket-1
2022-08-16 10:49:42 my-code2care-bucket-2
Example 2: To get a list of all objects within a specific S3 bucket,
% aws s3 ls s3://my-code2care-bucket-1
Output:
2022-08-16 11:13:09 13 test.txt
2022-08-16 11:13:23 131 myfile.txt
Example 3: To get a list of all s3 buckets that match the regex,
Note: Though this is not a completely s3 command but a combination of grep to filter out what you want to see,
% aws s3 ls | grep my*
2022-08-16 10:44:36 my-cod2care-bucket-1
2022-08-16 10:49:42 my-code2care-bucket-2
Example 4: List all the Recursively prefixes and objects in a bucket --recursive
% aws s3 ls s3://my-code2care-bucket-1 --recursive
2022-08-16 11:53:12 0 myfiles/a.txt
2022-08-16 11:53:12 0 myfiles/b.txt
2022-08-16 11:53:12 13 test.txt
Example 5: Limit the number of results returned by the ls command, --page-size (default 1000)
% aws s3 ls --page-size 50
Example 6: Display objects/file size in human-readable format: --human-readable
% aws s3 ls s3://my-code2care-bucket-1 --human-readable
PRE myfiles/
2022-08-16 11:53:12 13 Bytes test.txt
Example 7: Display the total number of objects and size of the bucket
% aws s3 ls s3://my-code2care-bucket-1 --summarize
PRE myfiles/
2022-08-16 11:53:12 13 test.txt
Total Objects: 1
Total Size: 13
Example 8: Display the total number of objects and size of the bucket in human-readable sizes Bytes/MiB/KiB/GiB/TiB/PiB/EiB
% aws s3 ls s3://my-code2care-bucket-1 --summarize --human-readable
PRE myfiles/
2022-08-16 11:53:12 13 Bytes test.txt
Total Objects: 1
Total Size: 13 Bytes
More Posts related to AWS,
- Create S3 bucket and upload files using AWS Toolkit for Visual Studio Code
- Get the total size and number of objects of a AWS S3 bucket and folders
- Create an S3 bucket in a specific AWS region using CLI Command
- [Solution] AWS Java SDK S3 AmazonS3Exception InvalidAccessKeyId
- Fix AWS CLI 2 SignatureDoesNotMatch Error - Signature we calculated does not match
- 573 List of reserved keywords in AWS DynamoDB
- Quick way to setup AWS DynamoDB locally on macOS
- [Solution] com.amazonaws.dynamodb.v20120810 MissingAuthenticationToken Key Id or X.509 certificate
- Quick way to install AWS CLI for macOS Terminal
- Setting and Updating AWS CLI Configuration
- AWS S3 CLI BucketAlreadyExists when calling CreateBucket Error make_bucket failed
- How to install AWS Toolkit for Visual Studio Code
- Create S3 bucket using AWS CLI Command mb
- Fix: zsh: command not found: aws (Mac/macOS)
- How to install AWS CLI on Ubuntu
- Fix: Amazon Linux bash: sudo: command not found
- How to Setup AWS Credentials using Visual Studio Code
- AW3 CLI command to get list of all region names
- Most Essencial AWS CLI 2 S3 ls Command Options
- Install AWS CLI using Brew Command
More Posts:
- Location of eclipse.ini file on Mac OS X - Mac-OS-X
- Eclipse: Updating Maven Project. Unsupported IClasspathEntry kind=4 - Eclipse
- Notepad++ Editor alternatives for macOS - NotepadPlusPlus
- Java Jackson ObjectMapper Class with Examples - Java
- Steps to Delete or Deactivate Instagram Account - HowTos
- Fibonacci series from 1 to 500 table - Html
- [Docker] Install Git on Alpine Linux - Docker
- [Fix] Modern authentication failed here, but youll still be able to sign in. Your status code is 4c7 - Microsoft Teams - Teams