The difference is in .tg.gz and first gz and then tar

I made two compressed copies of my folder, first using the command tar czf dir.tar.gz dir This gives me an archive of ~ 16kb in size. Then I tried another method, first I destroyed all the files inside the directory, and then used

gzip ./dir/*
tar cf dir.tar dir/*.gz

but the second method gave me dir.tar of size ~ 30kb (almost doubled). Why are there so many size differences?

+3
source share
3 answers

Since the zip process is generally more efficient for a large sample than for small files. For example, you encrypted 100 files from 1ko. Each file will have a specific compression, as well as service data of the gzip format .

file1.tar -> files1.tar.gz  (admit 30 bytes of headers/footers)
file2.tar -> files2.tar.gz  (admit 30 bytes of headers/footers)
...
file100.tar -> files100.tar.gz  (admit 30 bytes of headers/footers)
------------------------------
30*100 = 3ko of overhead.

tar 100ko ( 100 ), gzip ( 100 ), )

+5

gzip - gzip , , (reset ).

+2

tar cf should create an uncompressed archive, which means that the size of your directory should be almost the same as your archive, maybe even larger.

tar czfwill perform compression gunzipthrough it.

You can further verify this by running man tara command prompt on Linux,

   -z, --gzip, --gunzip, --ungzip
          filter the archive through gzip
-1
source

All Articles