Note: Before Running this script please configure your AWS CLI.
#!/bin/bash
for bucketlist in $(aws s3api list-buckets | jq --raw-output '.Buckets[].Name');
do
echo "* $bucketlist"
listobjects=$(\
aws s3api list-objects --bucket $bucketlist \
--query 'Contents[*].Key')
#echo "==$listobjects=="
if [[ "$listobjects" == "null" ]]; then
echo "$bucketlist is empty"
echo $bucketlist >> emptyBucketList.txt
fi
done
for bucketlist in $(aws s3api list-buckets | jq --raw-output '.Buckets[].Name');
do
echo "* $bucketlist"
listobjects=$(\
aws s3api list-objects --bucket $bucketlist \
--query 'Contents[*].Key')
#echo "==$listobjects=="
if [[ "$listobjects" == "null" ]]; then
echo "$bucketlist is empty"
echo $bucketlist >> emptyBucketList.txt
fi
done
No comments:
Post a Comment