Skip to content

Instantly share code, notes, and snippets.

@jonmchan
Created April 15, 2025 15:04
Show Gist options
  • Save jonmchan/6be1f8f3e1b4ae3aa7f1bf921295ee6b to your computer and use it in GitHub Desktop.
Save jonmchan/6be1f8f3e1b4ae3aa7f1bf921295ee6b to your computer and use it in GitHub Desktop.
one-liner to delete all files within an S3 bucket
export AWS_DEFAULT_REGION=
export AWS_ACCESS_KEY_ID=
export AWS_SECRET_ACCESS_KEY=
aws --endpoint=https://<YOUR_ENDPOINT> s3 ls s3://<YOUR_BUCKET>/|awk '{print $4 }' | xargs -I {} -d\\n -n1 aws --endpoint=https://<YOUR_ENDPOINT> s3 rm s3://<YOUR_BUCKEt>/{}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment