Skip to content

Instantly share code, notes, and snippets.

@aphexmunky
Created January 11, 2018 10:21
Show Gist options
  • Save aphexmunky/33b0dc0ae7c12bca3f1e12bf8447dccd to your computer and use it in GitHub Desktop.
Save aphexmunky/33b0dc0ae7c12bca3f1e12bf8447dccd to your computer and use it in GitHub Desktop.
Downloads the latest file in the root of an s3 bucket presuming the directory has the same name as the bucket
#!/bin/bash │2017-12-28 17:35:07 93049433 location-report-28-12-2017-17:00:22.csv
│2017-12-29 00:35:07 92385322 location-report-29-12-2017-00:00:21.csv
dir=`basename $PWD` │2017-12-29 10:34:04 88874615 location-report-29-12-2017-10:00:21.csv
download=`aws s3 ls s3://$dir/ | sort | tail -n 1 | awk '{print $4}'` │2017-12-29 17:34:40 89295406 location-report-29-12-2017-17:00:21.csv
aws s3 cp s3://$dir/$download . │2017-12-30 00:34:09 89133691 location-report-30-12-2017-00:00:21.csv
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment