Skip to content

Instantly share code, notes, and snippets.

@flavono123
Last active August 3, 2022 10:09
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save flavono123/8a1f1bdaee429091c01713c7063de968 to your computer and use it in GitHub Desktop.
Save flavono123/8a1f1bdaee429091c01713c7063de968 to your computer and use it in GitHub Desktop.
Aggregate the latest 'LastModified' of S3 objects by prefixes
#!/bin/bash
bucket=$1
prefixes=( "${@:2}" )
for prefix in "${prefixes[@]}"
do
lm=$(aws s3api list-objects-v2 --bucket="${bucket}" --prefix="${prefix}" | jq '.Contents | map(.LastModified) | sort_by(.)[-1]')
echo "${prefix}\t${lm}"
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment