【问题标题】:Does ungzipping the result of concatenating two gzipped files always equal the result of concatenating the two files in their raw and ungzipped form?解压缩连接两个 gzip 文件的结果是否总是等于连接原始和解压缩形式的两个文件的结果?
【发布时间】:2012-11-29 02:32:43
【问题描述】:

在我的简短测试中,情况确实如此,但我想知道是否可以依赖该属性。

无论file1file2的内容如何,​​file3是否总是等于file4

cat file1 file2 > file3
gzip file1
gzip file2
cat file1.gz file2.gz | gunzip - > file4

# Are file3 and file4 necessarily the same?

【问题讨论】:

    标签: linux bash shell unix gzip


    【解决方案1】:

    根据手册页,是的。这是记录在案的行为。

    http://www.gnu.org/software/gzip/manual/html_node/Advanced-usage.html

    高级用法

    可以连接多个压缩文件。在这种情况下,gunzip 将一次提取所有成员。如果一个成员损坏,另一个 移除损坏的成员后,成员可能仍会被恢复。 如果所有成员都被压缩,通常可以获得更好的压缩 解压缩,然后在一个步骤中重新压缩。

    这是连接 gzip 文件的示例:

     gzip -c file1  > foo.gz
     gzip -c file2 >> foo.gz Then
    
     gunzip -c foo is equivalent to
    
     cat file1 file2
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2017-01-18
      • 1970-01-01
      • 2010-09-21
      • 1970-01-01
      • 2017-04-02
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多