【问题标题】:How to read the head of a .gz file using AWS S3 , without downloading the file如何使用 AWS S3 读取 .gz 文件的头部,而无需下载文件
【发布时间】:2018-06-01 19:13:49
【问题描述】:

我正在尝试使用 awscli 读取 gz 文件的头部而不下载。我正在使用命令

aws s3api get-object --bucket mybucket_name --key path/to/the/file.log.gz --range bytes=0-10000 /dev/stdout | zless 

我在link https://stackoverflow.com/questions/25983769/head-command-for-aws-s3-to-view-file-contents?utm_medium=organic&utm_source=google_rich_qa&utm_campaign=google_rich_qa 中找到的

我能够读取简单 txt 文件的开头,但如何读取 .gz 文件。或者如果可以使用其他工具的任何其他方式?

【问题讨论】:

标签: amazon-web-services unix amazon-s3


【解决方案1】:

一个简单的方法是:-

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

对于gz文件,你可以这样做

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

【讨论】:

    猜你喜欢
    • 2021-11-22
    • 2020-01-18
    • 1970-01-01
    • 1970-01-01
    • 2022-01-14
    • 2015-04-18
    • 2020-09-17
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多