How to write a 'tar' command

sebastiancarlos@lemmy.sdf.org to Linux@lemmy.ml – 840 points –
155

You are viewing a single comment

just now realizing that .tar files aren't compressed by default, and that that's the reason why it's always .tar.gz

tar was originally was for tape archiving so it's just a stream of headers and files which end up directed to a file or a device. It's not well ordered, just whatever file happens to be found next is the next in the stream. When you compress the tar this stream it's just piped through gzip or bzip2 on its way.

The tradeoff for compressing this way is if you want to list the contents of the tar then you essentially have to decompress and stream through the whole thing to see what's in it unlike a .zip or .7z where there would be a separate index at the end which can be read far more easily.