Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Recursive list s3 bucket contents with AWS CLI

How can I recursively list all all the contents of a bucket using the AWS CLI similar to using find . on Unix.

aws s3 ls s3://MyBucket --recursive complains with unknown option.

http://docs.aws.amazon.com/cli/latest/reference/s3/index.html#directory-and-s3-prefix-operations claims that --recursive is a valid parameter.

like image 969
Klugscheißer Avatar asked Dec 18 '13 16:12

Klugscheißer


People also ask

What CLI command will list all of the S3 buckets you have access to?

To list your buckets, folders, or objects, use the s3 ls command. Using the command without a target or options lists all buckets.

What is recursive in AWS CLI?

When passed with the parameter --recursive the aws s3 cp command recursively copies all objects from source to destination. It can be used to download and upload large set of files from and to S3.

How do I get files from AWS command line S3?

You can use cp to copy the files from an s3 bucket to your local system. Use the following command: $ aws s3 cp s3://bucket/folder/file.txt . To know more about AWS S3 and its features in detail check this out!


2 Answers

aws s3 ls s3://MyBucket --recursive works fine for me.

Try updating your AWS CLI. My version is aws-cli/1.6.2

aws --version

like image 113
wisbucky Avatar answered Sep 20 '22 23:09

wisbucky


With recent AWS CLI versions, --recursive option is supported.

You can list recursively all the files under a bucket named MyBucket using following command:

aws s3 ls s3://MyBucket/ --recursive 

You can list recursively all the files under a folder named MyFolder in the bucket, using following command:

aws s3 ls s3://MyBucket/MyFolder/ --recursive 

For more information, see: https://docs.aws.amazon.com/cli/latest/reference/s3/ls.html

like image 35
veben Avatar answered Sep 21 '22 23:09

veben