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 create a tar file?
- How do I compress a file using gzip and tar.xz?
- How do I use the Unix tar xvf command to extract files?
- How do I use tar gzip with a password?
- How can I fix an unexpected end of file error when compressing a file with tar and gzip?
- How do I create a tar.zip file in Unix?
- How do I use gzip tar xvf to extract a file?
- How do I use the tar command line in Windows 10?
- How do I use gzip and tar in Linux?
- How do I use the tar command on Windows?
See more codes...