Skip to content

Instantly share code, notes, and snippets.

@floehopper
Created November 21, 2017 10:34
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 floehopper/ceed820ec6a2502200ac7d1faf41a4c9 to your computer and use it in GitHub Desktop.
Save floehopper/ceed820ec6a2502200ac7d1faf41a4c9 to your computer and use it in GitHub Desktop.
$ aws s3api list-objects-v2 --bucket govuk-assets-integration --query 'Contents[?length(@.Key) == `24`].[Key]' --output text >orphan-s3-object-keys.txt
$ cat orphan-s3-object-keys.txt | wc -l # => 1137
$ cat orphan-s3-object-keys.txt | xargs -I {} aws s3api delete-object --bucket govuk-assets-integration --key {}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment