如何排序的输出" s3cmd LS" [英] How to sort output of "s3cmd ls"
问题描述
亚马逊s3cmd LS发生这样的输出:结果
2010-02-20 21:01 1458414588 S3://file1.tgz.00结果
2010-02-20 21:10 1458414527 S3://file1.tgz.01结果
2010-02-20 22:01 1458414588 S3://file2.tgz.00结果
2010-02-20 23:10 1458414527 S3://file2.tgz.01结果
2010-02-20 23:20 1458414588 S3://file2.tgz.02结果
结果
如何选择归档的所有文件,在截至00 ... XX,与文件集的最新日期?
日期和时间进行排序。
猛砸,正则表达式?
感谢名单!
日期= $(s3cmd LS |排序-n |尾-n 1 | awk的'{$打印1})
s3cmd LS | grep的$ DATE
排序多项schould把年轻的最后日期。尾-n1取最后一行,AWK切割的第一个字是日期。用它来获取该日期的所有条目。
但也许我不明白这个问题 - 让你不得不改换。你告诉我们日期和时间不排序,并提供他们进行排序的例子 - 你问的最后日期,但所有条目都有相同的日期。
Amazon "s3cmd ls" takes like this output:
2010-02-20 21:01 1458414588 s3://file1.tgz.00
2010-02-20 21:10 1458414527 s3://file1.tgz.01
2010-02-20 22:01 1458414588 s3://file2.tgz.00
2010-02-20 23:10 1458414527 s3://file2.tgz.01
2010-02-20 23:20 1458414588 s3://file2.tgz.02
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!
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.
这篇关于如何排序的输出" s3cmd LS"的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!