Aws s3

From Wasya Wiki
Revision as of 15:22, 30 March 2026 by Piousbox (Talk | contribs)

(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search

get size of bucket

 aws s3 ls s3://your-bucket-name --recursive --summarize --human-readable

remove objects that start with ._

 export bucket='your-bucket-name'

Preview:

 aws s3api list-objects-v2 \
   --bucket $bucket \
   --query "Contents[?starts_with(Key, '._') || contains(Key, '/._')].Key"

execute:

 aws s3api list-objects-v2 \
   --bucket $bucket \
   --query "Contents[?starts_with(Key, '._') || contains(Key, '/._')].Key" \
   --output text | tr '\t' '\n' | while read key; do
     aws s3 rm "s3://$bucket/$key"
   done