#!/bin/bash BUCKET= PROFILE_OTHER= PROFILE_MINE= DATE=$(date +%Y-%m-%dT%H:00:00) IFS=$'\t' for KEY in $(aws --profile $PROFILE_MINE s3api list-objects --bucket $BUCKET --query 'Contents[?LastModified>="'$DATE'"][].Key' --output text) do echo $KEY # grant access to the account holder aws --profile $PROFILE_OTHER s3api put-object-acl --bucket $BUCKET --key "$KEY" --acl bucket-owner-full-control # make the object public aws --profile $PROFILE_MINE s3api put-object-acl --bucket $BUCKET --key "$KEY" --acl public-read done