如何对“s3cmd ls”的输出进行排序
Amazon“s3cmd ls”采用如下输出:
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>
如何选择以 00 ... XX 结尾且文件集最新日期的所有存档文件?
日期和时间未排序。
bash、正则表达式?
谢谢!
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!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
这将按日期升序排序。
This will sort by date ascending.
按数字排序应将最年轻的日期放在最后。 tail -n1 获取最后一行,awk 剪切第一个单词,即日期。用它来获取该日期的所有条目。
但也许我不明白这个问题 - 所以你必须重新表述。您告诉我们“日期和时间未排序”并提供了一个对它们进行排序的示例 - 您要求最新日期,但所有条目都具有相同的日期。
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.
尝试
此命令语法为 s3 ls s3:// 存储桶/文件的路径 | sort
最后会按照日期降序排序
Try
This command syntax is s3 ls s3:// path of the bucket / files | sort
It will sort in the descending date at last
只需附加
| sort
到您的s3cmd ls
命令以按日期排序。最新的文件将出现在命令行的正上方。s3cmd ls s3://path/to/file | s3cmd ls s3://path/to/file |排序
Simply append
| sort
to yours3cmd ls
command to sort by date. The most recent file will appear right above your command line.s3cmd ls s3://path/to/file | sort