Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

We commonly know that compression is the reduction in size of data in order to save space or transmission time, I should expect bigger size when I extract compressed file. I have downloaded a file in tar format(95KB) and when I extracted it its size reduced(5.7KB) and under that there were some other files which are even showing 0byte now. What may be the reason of it.

share|improve this question

1 Answer 1

up vote 7 down vote accepted

Tar format is not compressed. But it does add headers at the start of each file or directory in the archive. The headers are used by tar to tell it the name of the file, the timestamp, etc. That information isn't part of the data inside the file but tar needs it to recreate the file. Each header is usually 512 bytes but could be larger if the filename is longer than 100 characters. The end of a tar archive is marked by a blank header. Those headers usually explain any difference in size between the archive and everything extracted from it.

There could also be differences that can't be explained by the size of the tar headers but they're mostly corner cases and hard to diagnose without seeing the tar file or at least a listing of it. One possible explanation for a huge difference, a huge tar file but very little extracted from it, is if the archive contains lots of copies of the same file. This could happen if someone kept adding newer versions onto the end, perhaps as a backup strategy. The tar extraction would simply keep overwriting that same file each time without using more space.

share|improve this answer
    
Thanks, So you are saying those headers get removed when I extract the file ? –  Subhransu Sep 30 '12 at 14:32
    
So to speak. The headers are used by tar to tell it the name of the file, the timestamp, etc. That information isn't part of the data inside the file but tar needs it to recreate the file. –  Nicole Hamilton Sep 30 '12 at 15:09
    
I've updated my answer a bit. I hope that's helpful. Thanks for the accept. –  Nicole Hamilton Feb 8 '13 at 18:09

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.