How to sort output of "s3cmd ls"

DATE=$(s3cmd ls | sort -n | tail -n 1 | awk '{print $1}')
s3cmd ls | grep $DATE 

sorting as a number schould put youngest dates last. Tail -n1 takes the last line, awk cuts the first word which is the date. Use that to get all entries of that date.

But maybe I didn't understand the question - so you have to rephrase it. You tell us 'date and time is not sorted' and provide an example where they are sorted - you ask for the latest date, but all entries have the same date.


Try

This command syntax is s3 ls s3:// path of the bucket / files | sort

s3cmd ls s3://file1.tgz.00<br>  | sort

It will sort in the descending date at last


s3cmd ls s3://bucket/path/ | sort -k1,2

This will sort by date ascending.