Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Keiku/b4dd802623e55c03f9e20d46c43a4471 to your computer and use it in GitHub Desktop.
Save Keiku/b4dd802623e55c03f9e20d46c43a4471 to your computer and use it in GitHub Desktop.
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