
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:
- How to change the KeyMap in Android Studio - Android-Studio
- How to delete a file using PowerShell [Windows/macOS] - Powershell
- M1/M2 Mac VirtualBox Unsupported hardware architecture detected! - MacOS
- [Docker M1/M2 Mac] qemu-x86_64: Could not open /lib64/ld-linux-x86-64.so.2: No such file or directory AWS CLI - Docker
- wget Command on macOS Terminal - MacOS
- Android Parsing Data for android-L failed Unsupported major.minor version 51.0 Error - Android
- [Fix] java: integer number too large compilation error - Java
- Setting up Java JUnit Project with Eclipse + Maven Example - Java