How to display only files from aws s3 ls command?

后端 未结 9 846
北恋
北恋 2021-01-01 08:09

I am using the aws cli to list the files in an s3 bucket using the following command (documentation):

aws s3 ls s3://mybucket --recursive --human-readable --         


        
9条回答
  •  攒了一身酷
    2021-01-01 09:02

    My Solution

    List only files recursively using aws cli.

    aws s3 ls s3://myBucket --recursive | awk 'NF>1{print $4}' | grep .
    

    grep . - Clear empty lines.


    Example: aws s3 ls s3://myBucket

                               PRE f5c10c1678e8484482964b8fdcfe43ad/
                               PRE f65b94ad31734135a61a7fb932f7054d/
                               PRE f79b12a226b542dbb373c502bf125ffb/
                               PRE logos/
                               PRE test/
                               PRE userpics/
    2019-05-14 10:56:28       7754 stage.js
    

    Solution: aws s3 ls s3://myBucket --recursive | awk 'NF>1{print $4}' | grep .

    stage.js
    

提交回复
热议问题