s3cmd 内容列表 - 只有文件名 - perl one liner?

use*_*048 2 perl s3cmd

目前我正在使用s3cmd ls s3://location/ > file.txt获取我的 s3 存储桶的内容列表并保存在 txt 中。但是,上述返回日期、文件大小路径和文件名。

例如:

2011-10-18 08:52      6148   s3://location//picture_1.jpg
Run Code Online (Sandbox Code Playgroud)

我只需要 s3 存储桶的文件名 - 所以在上面的例子中我只需要picture_1.jpg.
有什么建议?

这可以在初始导出后使用 Perl one liner 完成吗?

Con*_*ine 5

使用 awk:

s3cmd ls s3://location/ | awk '{ print $4 }' > file.txt
Run Code Online (Sandbox Code Playgroud)

如果您的文件名带有空格,请尝试:

s3cmd ls s3://location/ | awk '{ s = ""; for (i = 4; i <= NF; i++) s = s $i " "; print s }' > file.txt
Run Code Online (Sandbox Code Playgroud)