【问题标题】:Decompress tar before reading阅读前解压tar
【发布时间】:2015-10-26 08:58:12
【问题描述】:

在读取 gzip 压缩的 tar 文件时 decompress -z 标志有什么不同?

//Without unzipping
sysadmin@localhost:~/Documents$ tar -tf logs.tar.gz                             
logs/                                                                           
logs/access_log.1                                                               
logs/access_log.2                                                               
logs/access_log.3                                                               
logs/access_log.4                                                               

////With unzipping
sysadmin@localhost:~/Documents$ tar -tzf logs.tar.gz                            
logs/                                                                           
logs/access_log.1                                                               
logs/access_log.2                                                               
logs/access_log.3                                                               
logs/access_log.4  

内容似乎在这两种情况下都正确显示。

【问题讨论】:

    标签: linux gzip compression


    【解决方案1】:

    2004 年:来自 /usr/doc/tar-1.15.1/NEWS ,Slackware 10.2 ...

    version 1.15 - Sergey Poznyakoff, 2004-12-20
    
    * Compressed archives are recognised automatically, it is no longer
    necessary to specify -Z, -z, or -j options to read them. 
    ( Thus, you can now run `tar tf archive.tar.gz'.)
    

    而 2009 年,lzma 解压被添加到 tar 中,自动识别:后缀 .xz

    【讨论】:

      【解决方案2】:

      -z 首次引入时,解压缩档案时需要它。后来(也许是为了使用-j 来帮助bzip2 支持)有人修改了GNU tar 以进行检查并自动执行此操作。自动检查是可能的,因为文件的前几个字节具有独特的“神奇”值。

      相对于-z 选项,更改(当然是tar)是最近才发生的:我在更改日志中没有明确看到它,但是关于2010 年lzip 的“魔术”的评论听起来很相关,而在 1997 年的条目中提到了“压缩”。

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 1970-01-01
        • 2016-01-25
        • 2022-01-14
        • 1970-01-01
        • 2016-10-08
        • 2011-02-22
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多