How to use aws s3 ls command – AWS S3 Tutorial
5 years ago Lalit Bhagtani 0
In this tutorial, we will learn about how to use aws s3 ls command using aws cli.
ls Command
The ls command is used to get a list of buckets or a list of objects and common prefixes under the specified bucket name or prefix name.
Optional Arguments
This command takes the following optional arguments :-
- path :- It is an S3 URI of the bucket or its common prefixes.
- –recursive :- It performs list operation for a specified bucket and all of its prefixes.
- –page-size (integer) :- It returns the specified number of results in each response to a list operation.
- –human-readable :- It displays file sizes in a human readable format.
- –summarize :- It displays summary information like the number of objects and total size.
- –request-payer (String) :- It confirms that the requester knows that she or he will be charged for the request. Bucket owners need not to specify this parameter in their requests.
Syntax
aws s3 ls <S3Uri> [--recursive] [--pagesize] [--summarize] [--human-readable]
Examples
Get Bucket List
The aws s3 ls command can be used to get a list of buckets owned by the user. The syntax of the command is as follows:-
Syntax
aws s3 ls
Output
<Created Date> <Bucket Name>
Example
Get Objects & Prefixes of Bucket
The aws s3 ls command with the s3Uri option can be used to get a list of objects and common prefixes under the specified bucket name or prefix name. The syntax of the command is as follows:-
Syntax
aws s3 ls <s3Uri>
Output
PRE <Prefix Name>
<Created Date> <Size> <Object Name>
Example
Get all Objects & Prefixes of Bucket
The aws s3 ls command with the s3Uri and the recursive option can be used to get a list of all the objects and common prefixes under the specified bucket name or prefix name. The syntax of the command is as follows:-
Syntax
aws s3 ls <s3Uri> --recursive
Output
<Created Date> <Bucket Name>
<Created Date> <Prefix Name>
Example
Similar Post
- How to use aws s3 sync command
- How to copy object from one S3 bucket to another using Java
- How to use aws s3 sync command
- How to get a list of objects stored in S3 using Java
References :-
If you liked it, please share your thoughts in comments section and share it with others too.