How to sort output of "s3cmd ls"

dba.in.ua picture dba.in.ua · Apr 20, 2010 · Viewed 9.6k times · Source

Amazon "s3cmd ls" takes like this output:

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 files of archive, ending at 00 ... XX, with the latest date of fileset ?

Date and time is not sorted.

Bash, regexp ?

Thanx!

Answer

Erik Kristensen picture Erik Kristensen · Jun 11, 2014
s3cmd ls s3://bucket/path/ | sort -k1,2

This will sort by date ascending.