Skip to content

Instantly share code, notes, and snippets.

@MrHassanMurtaza
Last active June 16, 2021 10:26
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 MrHassanMurtaza/fd116038505bccd81f01a66f2755f1b8 to your computer and use it in GitHub Desktop.
Save MrHassanMurtaza/fd116038505bccd81f01a66f2755f1b8 to your computer and use it in GitHub Desktop.
Getting latest s3 bucket's object
#!/bin/bash
set -x
set -e
S3_BUCKET=""
S3_PREFIX=""
OBJECT="$(aws s3 ls s3://$S3_BUCKET/$S3_PREFIX | sort | tail -n 1 | awk '{print $4}')"
[ -z "$OBJECT" ] && echo "Object not found in S3 Bucket." && exit 1
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment