“head” command for aws s3 to view file contents

前端 未结 8 1292
不知归路
不知归路 2021-02-06 22:44

On Linux, we generally use the head/tail commands to preview the contents of a file. It helps in viewing a part of the file (to inspect the format for instance), rather than ope

8条回答
  •  终归单人心
    2021-02-06 23:18

    One easy way to do is :-

    aws s3api get-object --bucket bucket_name --key path/to/file.txt  --range bytes=0-10000 /path/to/local/t3.txt | cat t3 | head -100
    

    For the gz file , you can do

    aws s3api get-object --bucket bucket_name --key path/to/file.gz  --range bytes=0-10000 /path/to/local/t3 | zless t3 | head -100
    

    If the data is being less, incerease the amount of bytes required

提交回复
热议问题