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,
- Get the total size and number of objects of a AWS S3 bucket and folders
- How to Create AWS SNS Topic using AWS CLI
- Fix: Amazon Linux bash: sudo: command not found
- [Solution] AWS Java SDK S3 AmazonS3Exception InvalidAccessKeyId
- Create an AWS User using CLI2 Command at a specific Path
- Fix: Missing the following required SSO configuration values: sso_start_url, sso_region
- Fix: zsh: command not found: aws (Mac/macOS)
- Configure AWS Access ID and Secret Keys using CLI on Mac
- Quick way to setup AWS DynamoDB locally on macOS
- Most Essencial AWS CLI 2 S3 ls Command Options
- How to Check AWS SNS Permissions using CLI
- AWS CLI Change Default Output Format
- How to install AWS CLI on Ubuntu
- Quick way to install AWS CLI for macOS Terminal
- Install AWS CLI using Brew Command
- AWS CLI Command to Get a List of SNS Topics
- Get List of AWS SNS Topic Subscriptions using CLI
- How to Setup AWS Credentials using Visual Studio Code
- Installing AWS CLI Version 2 on macOS Sonoma using Terminal
- AW3 CLI command to get list of all region names
- AWS SNS CLI Command Publish Message Attributes
- Create an S3 bucket in a specific AWS region using CLI Command
- [Fix] zsh: command not found: awscli [Mac Terminal]
- Understanding AWS Calculator: DynamoDB on-demand capacity
- [Solution] com.amazonaws.dynamodb.v20120810 MissingAuthenticationToken Key Id or X.509 certificate
More Posts:
- Python copy file from a source to destination - Python
- How to display directory tree in Mac Terminal - MacOS
- Android R Cannot Be Resolved To A Variable - Android
- How to turn off Facebook autoplay videos on timeline - Facebook
- Write to File in Java using BufferedWriter - Java
- PowerShell: How to Check if a Module is Already Installed - Powershell
- Sign in as different user missing in SharePoint 2013 how to enable - SharePoint
- How to rerun last command in Zsh shell - HowTos