Find the answer to your Linux question:
Results 1 to 2 of 2
Not sure if this is really in the right forum but here goes.... Looking for a way to extract individual compressed files from a compressed tarball WITHOUT tar -zxvf and ...
Enjoy an ad free experience by logging in. Not a member yet? Register.
  1. #1
    Just Joined!
    Join Date
    Aug 2009
    Posts
    8

    TAR and GZIP issues


    Not sure if this is really in the right forum but here goes....

    Looking for a way to extract individual compressed files from a compressed tarball WITHOUT tar -zxvf and then recompressing. Basically we need to be able to chunk out an individual compressed file while it still remains compressed.

    For whatever reason, when we tar out the single, then recompress it's destroying the file integrity. The files are so large that we can't just decompress the whole then pick out pieces, so that's out.

    We had looked at going in and extracting the bits and writing them elsewhere, but from what I understand about how tar and gzip work, we'd get garbage because the gzip algorithm is predicated on the overall file rather than the pieces when working with a tarball. To gunzip the individual pieces would rely upon the initial Huffman double encoded "rosetta stone" that was generated from the overall tarball structure, right? Without that "rosetta stone", we'd not be able to accurately decompressed the individual .gzs....and a reverse algorithm wouldn't work because the initial was encoded off of patterns that were present in the whole but may not be present in the individual.

    I'm a bit of a n00b, so I just need to check and make sure I've absorbed this all correctly. But, in case I've processed it all incorrectly and if there is a way or a script that can accomplish this, please point me in the right direction. Thanks.

  2. #2
    Linux Enthusiast
    Join Date
    Jan 2005
    Location
    Saint Paul, MN
    Posts
    630
    Quote Originally Posted by athos View Post
    Not sure if this is really in the right forum but here goes....

    Looking for a way to extract individual compressed files from a compressed tarball WITHOUT tar -zxvf and then recompressing. Basically we need to be able to chunk out an individual compressed file while it still remains compressed.

    For whatever reason, when we tar out the single, then recompress it's destroying the file integrity. The files are so large that we can't just decompress the whole then pick out pieces, so that's out.

    We had looked at going in and extracting the bits and writing them elsewhere, but from what I understand about how tar and gzip work, we'd get garbage because the gzip algorithm is predicated on the overall file rather than the pieces when working with a tarball. To gunzip the individual pieces would rely upon the initial Huffman double encoded "rosetta stone" that was generated from the overall tarball structure, right? Without that "rosetta stone", we'd not be able to accurately decompressed the individual .gzs....and a reverse algorithm wouldn't work because the initial was encoded off of patterns that were present in the whole but may not be present in the individual.

    I'm a bit of a n00b, so I just need to check and make sure I've absorbed this all correctly. But, in case I've processed it all incorrectly and if there is a way or a script that can accomplish this, please point me in the right direction. Thanks.
    Code:
    tar zxvf yourtarfilegoeshere  file_1_witihin_tarfile .... file_N_within_tarfile
    Note that if the file is within one or more directories it needs to be qualified with the path and it will be extracted in that path (relative to your current location.)

    If you need to know the "filenames" in the tarball:
    Code:
     tar zt yourtarfilegoeshere
    And yes the tar command does not need the "-" for the options and its addition is relativly new.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •