What is the difference between tar and zip?
tar
in itself just bundles files together (the result is called a tarball), while zip
applies compression as well.
Usually you use gzip
along with tar
to compress the resulting tarball, thus achieving similar results as with zip
.
For reasonably large archives there are important differences though. A zip
archive is a collection of compressed files. A gzipped tar is a compressed collection (of uncompressed files). Thus a zip archive is a randomly accessible list of concatenated compressed items, and a .tar.gz
is an archive that must be fully expanded before the catalog is accessible.
- 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).
Related videos on Youtube
mtk
http://mtktechiecode.blogspot.in/p/about-me.html http://mdtareque.github.io/cv/ https://code-bite.blogspot.in/ http://web.iiit.ac.in/~tareque.mohd/
Updated on July 22, 2022Comments
-
mtk almost 2 years
What is the difference between tar and zip? What are the use cases for each?
-
SomeKittens about 12 yearsSee these two answers from SuperUser: - Which is more efficient - tar or zip compression? What is the difference between tar and zip? - On Linux/Unix, does .tar.gz versus .zip matter? (By the way, StackOverflow is for programming problems. You'd probably do better asking questions like this at SuperUser in the future)
-
-
Dillon Ryan Redding almost 4 yearsI'm a little confused. The last paragraph and the list seem to contradict each other. A
zip
compresses files into a catalog, but the caveat is that you don't get compression across files? Similarly for.tar.gz
. Is there a typo in there? -
user2032201 almost 4 years@DillonRyanRedding Edited. Does this resolve your confusion?
-
Dillon Ryan Redding almost 4 yearsAha! That clears everything up. Thank you!