Sample Header Ad - 728x90

Limiting recursive 'aws s3 ls' searches by number of items in the folder

1 vote
1 answer
2656 views
Here's the scenario: I need to recursively search through tons and tons of folders and subfolders and spit out the results to a log file using the ls command, BUT, I need to stop searching a folder if it has more than 10~ objects? The reason being is once I have a sample of 10 items in a folder, I know what's in the folder, and since some folders contain tens of thousands of results, this will save lots of time. Why are you limited to 'ls'? Because I am searching S3, using the command aws s3 ls. The command aws s3 ls --summarize --recursive does what I need, I just now need a way to limit the search based on the number of items in a folder. I have tried using aws s3api list-buckets & list-objects and so forth, but even with the --max-values tag it doesn't do what I need. Thanks for your help.
Asked by Sidereal (111 rep)
Aug 3, 2018, 05:30 PM
Last activity: Sep 1, 2023, 05:03 AM