xxxxxxxxxx
# using s3 aws cli | sort by size
aws s3 ls \
s3://BUCKET_NAME/DIR_PATH/ \
--profile PROFILE \
| sort -k 3 -n -r
# OR
# using s3api aws cli | sort by size
aws s3api list-objects-v2 \
--bucket BUCKET_NAME \
--prefix DIR_PATH/ \
--output text \
--query 'sort_by(Contents, &Size)[*].{Key: Key, Size: Size}' \
--profile PROFILE