我正在使用aws cli使用以下命令( 文档 )来总结文件数量和s3存储桶的总大小:
aws s3 ls s3://mybucket --recursive --human-readable --summarize
这个命令给了我下面的输出:
2013-09-02 21:37:53 10 Bytes a.txt 2013-09-02 21:37:53 2.9 MiB foo.zip 2013-09-02 21:32:57 23 Bytes foo/bar/.baz/a 2013-09-02 21:32:58 41 Bytes foo/bar/.baz/b 2013-09-02 21:32:57 281 Bytes foo/bar/.baz/c 2013-09-02 21:32:57 73 Bytes foo/bar/.baz/d 2013-09-02 21:32:57 452 Bytes foo/bar/.baz/e 2013-09-02 21:32:57 896 Bytes foo/bar/.baz/hooks/bar 2013-09-02 21:32:57 189 Bytes foo/bar/.baz/hooks/foo 2013-09-02 21:32:57 398 Bytes z.txt Total Objects: 10 Total Size: 2.9 MiB
不过,我只是在Total Objects和Total Size输出之后,例如:
Total Objects: 10 Total Size: 2.9 MiB
我怎样才能显示Total Objects和Total Size同时压制/隐藏其余的?
或者使用tail来显示最后几行,或者grep根据行开始处的“Total”关键字(可选地带有额外的空格)过滤输出,如:
aws s3 ls s3://mybucket --recursive --human-readable --summarize|tail -n2
要么
aws s3 ls s3://mybucket --recursive --human-readable --summarize|grep -e '^\s*Total'