How to sort the output of "s3cmd ls"
Amazon "s3cmd ls" takes this result:
2010-02-20 21:01 1458414588 s3://file1.tgz.00<br> 2010-02-20 21:10 1458414527 s3://file1.tgz.01<br> 2010-02-20 22:01 1458414588 s3://file2.tgz.00<br> 2010-02-20 23:10 1458414527 s3://file2.tgz.01<br> 2010-02-20 23:20 1458414588 s3://file2.tgz.02<br> <br> How to select all archive files ending in 00 ... XX with the latest file set date?
Date and time are not sorted.
Bash, regexp?
Thanx!
DATE=$(s3cmd ls | sort -n | tail -n 1 | awk '{print $1}') s3cmd ls | grep $DATE sorting as a number can lead to the earliest dates. Tail -n1 takes the last line, awk cuts the first word, which is the date. Use this to get all entries for this date.
But maybe I did not understand the question, so you need to rephrase it. You tell us that โdate and time are not sortedโ and give an example of their sorting - you request the latest date, but all records have the same date.
s3cmd ls s3://bucket/path/ | sort -k1,2 It will sort by date in ascending order.