tar和zip的区别是什么?每个用例是什么?


Tar本身只是将文件捆绑在一起(结果称为tarball),而zip也应用压缩。

通常使用gzip和tar来压缩生成的tarball,从而获得与使用zip类似的结果。

然而,对于相当大的档案,有重要的区别。压缩档案是压缩文件的集合。gzip的tar是一个压缩的集合(未压缩的文件)。因此,zip归档是一个随机可访问的连接压缩项列表,而.tar.gz是一个必须在目录可访问之前完全展开的归档。

The caveat of a zip is that you don't get compression across files (because each file is compressed independent of the others in the archive, the compression cannot take advantage of similarities among the contents of different files); the advantage is that you can access any of the files contained within by looking at only a specific (target file dependent) section of the archive (as the "catalog" of the collection is separate from the collection itself). The caveat of a .tar.gz is that you must decompress the whole archive to access files contained therein (as the files are within the tarball); the advantage is that the compression can take advantage of similarities among the files (as it compresses the whole tarball).