Skip to content

Instantly share code, notes, and snippets.

@zh4n7wm
Last active March 5, 2025 02:52
Show Gist options
  • Save zh4n7wm/82d21f79c936ab5f89485e9ad8e819bf to your computer and use it in GitHub Desktop.
Save zh4n7wm/82d21f79c936ab5f89485e9ad8e819bf to your computer and use it in GitHub Desktop.
delete aliyun all oss buckets

delete all oss bucket from your aliyun account. (At Your Own Risk)

#!/bin/bash

for x in $(aliyun oss ls oss:// | grep -- 'oss-' | awk '{printf "%s|%s\n", $5, $7}'); do
    endpoint=$(echo "$x" | cut -d'|' -f1)
    bucket=$(echo "$x" | cut -d'|' -f2)
    echo "delete $bucket ..."
    aliyun oss rm "$bucket" -f -r --all-versions -b -e "$endpoint.aliyuncs.com"
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment