Skip to content

Instantly share code, notes, and snippets.

@nhp
Created May 15, 2018 16:00
Show Gist options
  • Save nhp/25095df24a614450c7ad99e8bafbee16 to your computer and use it in GitHub Desktop.
Save nhp/25095df24a614450c7ad99e8bafbee16 to your computer and use it in GitHub Desktop.
get latest file from given s3-bucket. Call it with ./s3-latest buckename foldername
#!/bin/bash
KEY=`aws s3 ls s3://$1/$2 --recursive | sort | tail -n 1 | awk '{print $4}'`
aws s3 cp s3://$1/$KEY ./$(basename $KEY)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment