Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. The Lounge
  3. Why do TAR files always need to be decompressed twice?

Why do TAR files always need to be decompressed twice?

Scheduled Pinned Locked Moved The Lounge
question
29 Posts 24 Posters 1 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • S Offline
    S Offline
    swampwiz
    wrote on last edited by
    #1

    I've noticed that whenever I download a TAR file (and it usually is TAR.GZ) and decompress it, there always is yet another compressed file that needs to be decompressed. Why don't folks just do a single compression?

    P L S M B 12 Replies Last reply
    0
    • S swampwiz

      I've noticed that whenever I download a TAR file (and it usually is TAR.GZ) and decompress it, there always is yet another compressed file that needs to be decompressed. Why don't folks just do a single compression?

      P Offline
      P Offline
      PIEBALDconsult
      wrote on last edited by
      #2

      Because a TAR file isn't a compressed file. A GZIP file is. So them UNIX folk put files in a TAR then GZIP it. Deal with it.

      1 Reply Last reply
      0
      • S swampwiz

        I've noticed that whenever I download a TAR file (and it usually is TAR.GZ) and decompress it, there always is yet another compressed file that needs to be decompressed. Why don't folks just do a single compression?

        L Offline
        L Offline
        Lost User
        wrote on last edited by
        #3

        double de-compression? you're doing it wrong. the proper [as per design] procedure: 1. un-gzip it and redirect the output to the tape device, ... (may necessitate co-ordinated use of 2 hands if tape device doesn't have automatic start/stop control) 2. rewind the tape ... (on some sites a separate rewinding machine - submit both the tape and duly completed rewind request) 3. and then: un-tar (tar -x) it from the tape reader into the destination directory. ... (please remember: folders are where you keep your forms and notes, files are stored in directories.) some new-fangled versions of tar have gzip built right in, many operators cant grok that. kids these days: always looking for shortcuts.

        This internet thing is amazing! Letting people use it: worst idea ever!

        P OriginalGriffO H 3 Replies Last reply
        0
        • L Lost User

          double de-compression? you're doing it wrong. the proper [as per design] procedure: 1. un-gzip it and redirect the output to the tape device, ... (may necessitate co-ordinated use of 2 hands if tape device doesn't have automatic start/stop control) 2. rewind the tape ... (on some sites a separate rewinding machine - submit both the tape and duly completed rewind request) 3. and then: un-tar (tar -x) it from the tape reader into the destination directory. ... (please remember: folders are where you keep your forms and notes, files are stored in directories.) some new-fangled versions of tar have gzip built right in, many operators cant grok that. kids these days: always looking for shortcuts.

          This internet thing is amazing! Letting people use it: worst idea ever!

          P Offline
          P Offline
          PIEBALDconsult
          wrote on last edited by
          #4

          Files are not stored in directories. (Nor in folders of course.)

          L 1 Reply Last reply
          0
          • L Lost User

            double de-compression? you're doing it wrong. the proper [as per design] procedure: 1. un-gzip it and redirect the output to the tape device, ... (may necessitate co-ordinated use of 2 hands if tape device doesn't have automatic start/stop control) 2. rewind the tape ... (on some sites a separate rewinding machine - submit both the tape and duly completed rewind request) 3. and then: un-tar (tar -x) it from the tape reader into the destination directory. ... (please remember: folders are where you keep your forms and notes, files are stored in directories.) some new-fangled versions of tar have gzip built right in, many operators cant grok that. kids these days: always looking for shortcuts.

            This internet thing is amazing! Letting people use it: worst idea ever!

            OriginalGriffO Offline
            OriginalGriffO Offline
            OriginalGriff
            wrote on last edited by
            #5

            Tape? Tape? We don't use such new-fangled magnetics here! Send it to the card punch!

            Sent from my Amstrad PC 1640 Bad command or file name. Bad, bad command! Sit! Stay! Staaaay... AntiTwitter: @DalekDave is now a follower!

            "I have no idea what I did, but I'm taking full credit for it." - ThisOldTony
            "Common sense is so rare these days, it should be classified as a super power" - Random T-shirt

            L B 2 Replies Last reply
            0
            • S swampwiz

              I've noticed that whenever I download a TAR file (and it usually is TAR.GZ) and decompress it, there always is yet another compressed file that needs to be decompressed. Why don't folks just do a single compression?

              S Offline
              S Offline
              Super Lloyd
              wrote on last edited by
              #6

              In plain English: A tar file is an (uncompressed) file(sssss) archive. i.e. a group of files together as one file. GZip compress 1 file. The tar archive. So you do in 2 steps is: 1. uncompress 2. unarchive Now, it's about your tools. Some too unpack both steps as one. Maybe use different tools if doing in 2 step is a bother?

              A new .NET Serializer All in one Menu-Ribbon Bar Taking over the world since 1371!

              P 1 Reply Last reply
              0
              • P PIEBALDconsult

                Files are not stored in directories. (Nor in folders of course.)

                L Offline
                L Offline
                Lost User
                wrote on last edited by
                #7

                good point, the directory is just a list of name and inode number pairs. Such a simple system, could elegantly do things back then that NTFS still hasn't come close to without a whole mess of complicated hoops to jump through.

                This internet thing is amazing! Letting people use it: worst idea ever!

                P 1 Reply Last reply
                0
                • OriginalGriffO OriginalGriff

                  Tape? Tape? We don't use such new-fangled magnetics here! Send it to the card punch!

                  Sent from my Amstrad PC 1640 Bad command or file name. Bad, bad command! Sit! Stay! Staaaay... AntiTwitter: @DalekDave is now a follower!

                  L Offline
                  L Offline
                  Lost User
                  wrote on last edited by
                  #8

                  luxury! toggle switches!

                  This internet thing is amazing! Letting people use it: worst idea ever!

                  B K 2 Replies Last reply
                  0
                  • S swampwiz

                    I've noticed that whenever I download a TAR file (and it usually is TAR.GZ) and decompress it, there always is yet another compressed file that needs to be decompressed. Why don't folks just do a single compression?

                    M Offline
                    M Offline
                    megaadam
                    wrote on last edited by
                    #9

                    tar xvf file Does both in one comnand

                    ... such stuff as dreams are made on

                    M K S V 4 Replies Last reply
                    0
                    • M megaadam

                      tar xvf file Does both in one comnand

                      ... such stuff as dreams are made on

                      M Offline
                      M Offline
                      Maximilien
                      wrote on last edited by
                      #10

                      megaadam wrote:

                      tar xvf file

                      Memories, oh Memories!!!

                      I'd rather be phishing!

                      1 Reply Last reply
                      0
                      • S swampwiz

                        I've noticed that whenever I download a TAR file (and it usually is TAR.GZ) and decompress it, there always is yet another compressed file that needs to be decompressed. Why don't folks just do a single compression?

                        B Offline
                        B Offline
                        Bard
                        wrote on last edited by
                        #11

                        What program do you use to decompress? Winrar for instance decompresses in one step. 7zip on the other hand is not willing to make it simple for the user: [7-Zip / Discussion / Open Discussion:Treat .tar.gz extract as atomic operation?](https://sourceforge.net/p/sevenzip/discussion/45797/thread/5eb1b8d5/)

                        1 Reply Last reply
                        0
                        • S swampwiz

                          I've noticed that whenever I download a TAR file (and it usually is TAR.GZ) and decompress it, there always is yet another compressed file that needs to be decompressed. Why don't folks just do a single compression?

                          enhzflepE Offline
                          enhzflepE Offline
                          enhzflep
                          wrote on last edited by
                          #12

                          Simples. Formats like ZIP employ compression on a file-by-file basis. This is obviously prone to poor rates of compression as compared to a scheme that can compress the entire contents of an archive, or in some cases, data that is contained within lots of small files. The solution is to slap all of the files together first in a monolithic chunk. You then run compression on that chunk in the (almost always delivered) hope that you'll achieve a smaller output than if the compressed output of all the contained files was then glued together into a single chunk. TAR - turn a bunch of files into one. GZ - compress a file.

                          K 1 Reply Last reply
                          0
                          • S swampwiz

                            I've noticed that whenever I download a TAR file (and it usually is TAR.GZ) and decompress it, there always is yet another compressed file that needs to be decompressed. Why don't folks just do a single compression?

                            H Offline
                            H Offline
                            hpcoder2
                            wrote on last edited by
                            #13

                            What are you downloading? Most source code bundles are just compressed with the .gz extension. Maybe if there were a bunch of videos, jpeg or pdf files, which have inbuilt compression, then the uncompressed .tar file might be as short, if not shorter than the tar.gz file. But muscle memory will automatically add the z option to tar to invoke gzip to compress the output. Similar, there's little point is adding the -C option to scp when transferring a .tar.gz file.

                            1 Reply Last reply
                            0
                            • S swampwiz

                              I've noticed that whenever I download a TAR file (and it usually is TAR.GZ) and decompress it, there always is yet another compressed file that needs to be decompressed. Why don't folks just do a single compression?

                              D Offline
                              D Offline
                              Dougy83
                              wrote on last edited by
                              #14

                              .tgz and .tar.gz files are some file(s)/directory(ies) stored into a single tar (tape archive) file without compression, before being compressed using gzip. gzip (on its own) can only handle a single file. This is why it looks like it's compressed twice. I'm pretty sure if you specify the right arguments, you can decompress the .tgz with a single command.

                              1 Reply Last reply
                              0
                              • S Super Lloyd

                                In plain English: A tar file is an (uncompressed) file(sssss) archive. i.e. a group of files together as one file. GZip compress 1 file. The tar archive. So you do in 2 steps is: 1. uncompress 2. unarchive Now, it's about your tools. Some too unpack both steps as one. Maybe use different tools if doing in 2 step is a bother?

                                A new .NET Serializer All in one Menu-Ribbon Bar Taking over the world since 1371!

                                P Offline
                                P Offline
                                Paul Sanders the other one
                                wrote on last edited by
                                #15

                                Yes, what he said. You're probably used to ZIP files, which do both jobs in a single file format.

                                Paul Sanders http://www.alpinesoft.co.uk

                                1 Reply Last reply
                                0
                                • S swampwiz

                                  I've noticed that whenever I download a TAR file (and it usually is TAR.GZ) and decompress it, there always is yet another compressed file that needs to be decompressed. Why don't folks just do a single compression?

                                  P Offline
                                  P Offline
                                  pmauriks
                                  wrote on last edited by
                                  #16

                                  Because GZ refers to gzip - and TAR refers to Tape Archive - which is not compressed (though some Unixes do use "compress" to compress the files in the TAR archive as a default setting). You can decompress with -zxvf to do the decompress all in the one step. You probably also noticed that some have TGZ extensions, and some have TAR.GZ extensions - depending on the process used to create the archive. In short - the reason is the Unix tradition for small programs that do one thing well and allow you to pipe them into one another.

                                  1 Reply Last reply
                                  0
                                  • S swampwiz

                                    I've noticed that whenever I download a TAR file (and it usually is TAR.GZ) and decompress it, there always is yet another compressed file that needs to be decompressed. Why don't folks just do a single compression?

                                    P Offline
                                    P Offline
                                    PhM33
                                    wrote on last edited by
                                    #17

                                    A TAR file in your sense is indeed a TAR.GZ file, which embed two formats : TAR and GZ. Here's the process : 1. A TAR file is ceated, concatening several files together in their uncompressed form ; note that resulting TAR file is uncompressed, 2. A GZ file is created by compressing the previous TAR file. So to decompress a TAR.GZ file, you have to : 1. Decompress the compressed GZ file and 2. "Untar" (unarchive) the uncompressed resulting TAR file. Note that you can compress a TAR file with other popular compressors (bzip2 => TAR.BZ2, 7zip => TAR.7Z...).

                                    1 Reply Last reply
                                    0
                                    • enhzflepE enhzflep

                                      Simples. Formats like ZIP employ compression on a file-by-file basis. This is obviously prone to poor rates of compression as compared to a scheme that can compress the entire contents of an archive, or in some cases, data that is contained within lots of small files. The solution is to slap all of the files together first in a monolithic chunk. You then run compression on that chunk in the (almost always delivered) hope that you'll achieve a smaller output than if the compressed output of all the contained files was then glued together into a single chunk. TAR - turn a bunch of files into one. GZ - compress a file.

                                      K Offline
                                      K Offline
                                      kalberts
                                      wrote on last edited by
                                      #18

                                      enhzflep wrote:

                                      Formats like ZIP employ compression on a file-by-file basis. This is obviously prone to poor rates of compression as compared to a scheme that can compress the entire contents of an archive

                                      If you experience significantly better compression by merging a lot of small files into one, either your average file size is extremely small (like in one classical Unix study showing that for the system as a whole, more than 80% of the files were less than 5 kbytes). Or, you misinterpret data: it is not poorer compression, but more metadata, administrative information. One large file requires one descriptor, five thousand tiny files require five thousand descriptors. That is not poorer rate of compression, but similar to gathering the five thousand files into one even without compression: That would save the space of 4999 inodes, as well as the internal fragmentation loss - if file sizes are evenly distributed: half an allocation unit (/disk block) per file. You save space by making this huge file, but it has nothing to do with data compression. If you want to make an exact comparison, you cannot compare the size of the .tar file to the size of the .tar.gz file. That sure would give you the compression rate of the .tar file, but to created the .tar file you had to add a noticable amount of metadata. So what you save by having only one file/compression descriptor, you partially loose to .tar administrative information. I keep a number of 'archives' of many small files in .zip format, saving space due to the compression, of course, but also a lot is saved by not wasting 2 Kbyte on each file in internal fragmentation. Another advantage of .zipping up these file groups: I frequently move the files between machines on USB sticks. Writing a few thousand files to a USB stick takes a lot of time to create the files. I guess that it has to do with USB stick writes not being cached, at least not to the same degree, and file creation requires lots of writes, even if the file contents is done in one single write. Writing a single .zip archive to a USB stick is several times faster than writing two thousand tiny files. A similar situation: We run a fairly large build system, with about a hundred build agents. A build may be producing dozens, in some cases hundreds, of individual artifacts. On the central server, distributing these artifacts, the inode table exploded when each artifact was treated separately. We were forced to modify the b

                                      1 Reply Last reply
                                      0
                                      • M megaadam

                                        tar xvf file Does both in one comnand

                                        ... such stuff as dreams are made on

                                        K Offline
                                        K Offline
                                        Keith Barrow
                                        wrote on last edited by
                                        #19

                                        dingdingdingdingding!!!!!! We have a winner!!!!

                                        KeithBarrow.net[^] - It might not be very good, but at least it is free!

                                        1 Reply Last reply
                                        0
                                        • L Lost User

                                          double de-compression? you're doing it wrong. the proper [as per design] procedure: 1. un-gzip it and redirect the output to the tape device, ... (may necessitate co-ordinated use of 2 hands if tape device doesn't have automatic start/stop control) 2. rewind the tape ... (on some sites a separate rewinding machine - submit both the tape and duly completed rewind request) 3. and then: un-tar (tar -x) it from the tape reader into the destination directory. ... (please remember: folders are where you keep your forms and notes, files are stored in directories.) some new-fangled versions of tar have gzip built right in, many operators cant grok that. kids these days: always looking for shortcuts.

                                          This internet thing is amazing! Letting people use it: worst idea ever!

                                          H Offline
                                          H Offline
                                          hevisko
                                          wrote on last edited by
                                          #20

                                          I must agree, kids these days have all these slang wordings on phones, but can't grok that tar stands for TApe aRchive, i's jst s bvius.

                                          K 1 Reply Last reply
                                          0
                                          Reply
                                          • Reply as topic
                                          Log in to reply
                                          • Oldest to Newest
                                          • Newest to Oldest
                                          • Most Votes


                                          • Login

                                          • Don't have an account? Register

                                          • Login or register to search.
                                          • First post
                                            Last post
                                          0
                                          • Categories
                                          • Recent
                                          • Tags
                                          • Popular
                                          • World
                                          • Users
                                          • Groups