Aws-cli: aws s3 ls --recursive --max-depth

Created on 28 Jun 2017  路  2Comments  路  Source: aws/aws-cli

Add option --max-depth to limit the depth of recurse.

Let's say that I have a bunch of folders with daily dumps structured as /bucket/source/year/month/day/.... For each day there might be hundreds of files which I am not interested in. I just need to check out for each source which days I have the data available.

Currently I have like 60k of items in the bucket. The --recursive query takes like 40 seconds. By being able to specify the depth both the runtime the number of queries could reduce greatly.

closing-soon

Most helpful comment

Could you at least add a limit? In some cases it would be really convenient to not pull down a full directory (even at one level) but instead just pull a sample of it, without having to do multiple calls.

All 2 comments

I don't think that would help anything because there aren't really directories in s3 its all just a flat keyspace with prefixes that have slashes in them. So when we do s3 ls --recursive prefix we are really just doing a ListObjects API call and specifying the prefix parameter. So I don't think there is a way to do this without getting the results client side and then throwing away some of the results, which won't save you any time.

Could you at least add a limit? In some cases it would be really convenient to not pull down a full directory (even at one level) but instead just pull a sample of it, without having to do multiple calls.

Was this page helpful?
0 / 5 - 0 ratings