cli-tarHow do I compare Unix tar and zip files?
Comparing Unix tar and zip files
Unix tar and zip files are both archive formats used to package multiple files into a single file for easier storage and transport.
The two formats differ in their compression algorithms. Unix tar does not compress the files, while zip files use a lossless compression algorithm to reduce file size.
To compare the two formats, one can use the Unix command line. The following example code uses the tar
and zip
commands to compare the size of two files:
$ ls -lh file1.txt file2.txt
-rw-r--r-- 1 user staff 4.0K Feb 20 12:00 file1.txt
-rw-r--r-- 1 user staff 8.0K Feb 20 12:00 file2.txt
$ tar -cf files.tar file1.txt file2.txt
$ zip files.zip file1.txt file2.txt
$ ls -lh files.tar files.zip
-rw-r--r-- 1 user staff 12K Feb 20 12:02 files.tar
-rw-r--r-- 1 user staff 8.2K Feb 20 12:02 files.zip
The output of the commands shows that the zip file is smaller than the tar file, since the zip file was compressed.
In conclusion, zip files are generally smaller than tar files, but tar files have the advantage of not requiring any additional software to open the archive.
Helpful links
More of Cli Tar
- How do I use the command line to tar and zip files?
- How can I use tar commands to zip a file?
- How do I use gzip, tar, and zip to compress files?
- How do I use the shell to tar and zip files?
- How do I use the Unix tar zip command?
- How do I use the command line to tar and zip a file?
- How do I use the command line to tar and zip a file?
- How do I use the command line to tar and zip a file?
- How do I use the command line to tar and distribute files?
- How do I use the Unix tar xvf command to extract files?
See more codes...