OmG
OmG

Reputation: 18838

How to get top 100 files inside a bucket

I have a bucket on aws and I wanna download top 100 of files inside the specified bucket. I can get one specific file using s3cmd likes the following:

s3cmd get s3://bucket_name/file_name.m4a

How to get 100 of them using a command? Is there any option for the get?

Upvotes: 0

Views: 421

Answers (1)

OmG
OmG

Reputation: 18838

I don't know any solution for get option (it might exist). A solution which I found is:

s3cmd ls -r s3://bucket_name | grep -o 's3:.*' | head -n 100 | while read file; do s3cmd get $file; done

Something like this for rm can be found here.

Upvotes: 1

Related Questions