Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Remove S3 files before the specified last update time
# Remove S3 files before the specified last update time
# Reference: amazon s3 - aws cli s3 bucket remove object with date condition - Stack Overflow https://stackoverflow.com/questions/51375531/aws-cli-s3-bucket-remove-object-with-date-condition
aws s3 ls --recursive s3://path/to/ | awk '$1 < "2020-06-25 12:00:00" {print $4}' | xargs -n1 -t -I 'KEY' aws s3 rm s3://path/to/'KEY'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.