【问题标题】:tail | gzip gives different file length than gzip after tail尾巴 | gzip 在尾部后给出的文件长度与 gzip 不同
【发布时间】:2020-09-09 07:44:34
【问题描述】:

我想压缩文件的最后 N 个字节。然而,尾| gzip 在尾部后给出的输出长度与 gzip 不同。

tail --bytes=1000 ./input > ./output.tmp
gzip -k output.tmp

tail --bytes=1000 ./input | gzip > ./output.gz

stat --format=%n:%s *

input         : 4843152
output.gz     : 449
output.tmp    : 1000
output.tmp.gz : 460

为什么tail 然后gzip 给出460 字节,而tail | gzip 给出449 字节?

【问题讨论】:

标签: pipe gzip tail


【解决方案1】:

http://www.zlib.org/rfc-gzip.html#header-trailer

如果您压缩文件,原始文件名将记录在 FNAME 字段中。 如果压缩流,则没有原始文件名。

这似乎解释了你的情况。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2021-02-08
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多