0

Does tar gzip gzip the files before or after they are put into the tar ?

I'm not referring to the actual processing that takes place when the tar.gz is created but rather how it can be interpreted when decompressing.

Is it.

  1. A tar archive containing a series of gzipped files
  2. A tar archive of files which is then gzipped
Paul Taylor
  • 13,411
  • 42
  • 184
  • 351
  • It is a programmer asking the question and asking it because of a programing question so I think relevent to programmers – Paul Taylor Jul 01 '14 at 11:57
  • First tar and then gzip. Reference: https://superuser.com/questions/252065/gzip-without-tar-why-are-they-used-together – Ozair Kafray Feb 28 '22 at 08:11

1 Answers1

3

It's a tar archive of files which is then gzipped - you can break it into two steps if you prefer when decompressing:

gunzip <tarball>
tar xf <decompressed tarfile>
fquinner
  • 548
  • 5
  • 16
  • thankyou, so my problem is that I cannot untar/zip it from command line (I do it programmatically in Java) and there isnt space for the unzipped tar and the files themselves as they are extracted is it possible to create an archive more like 1> ( dont have to specifically use tar/gzip) ? – Paul Taylor Jul 01 '14 at 07:23
  • Very welcome... OK so if you don't have room for the files themselves are you then simply wanting to list each file contained inside or something like that? If zip rather than tgz is an option, you might have better luck with something like java.util.zip where you have nice native dependency and no external modules required. Otherwise it could be worth looking at http://stackoverflow.com/questions/7128171/how-to-compress-decompress-tar-gz-files-in-java. – fquinner Jul 01 '14 at 07:36
  • I have room for the files themselves, what I don't have room for is the .tar file AND the files themselves at the same time and using the Java compress lib mentioned in that post it seems to create the tar file whilst untarring, but I have a plan manually gzip all the files in the folder BEFORE tarring. Then the .tar file will be smaller hopefully small enough that I can untar it and then unzip each file one by one, should work shouldn't it ? – Paul Taylor Jul 01 '14 at 07:51
  • Hmm - I'm afraid this is drifting beyond my core competency having not worked directly with these libraries before but I expect what you want is something which gunzips the tarball AS it extracts it. So I think you're looking for something which will decompress the gzip file into a buffered stream, then a tar library which supports extracting from that stream. Possibly java.util.zip.GZIPInputStream in conjunction with https://code.google.com/p/jtar/ which seems to support this sort of behaviour? – fquinner Jul 01 '14 at 08:00
  • ok thks that might work as well. but ive tried my solution and that works well for me :) – Paul Taylor Jul 01 '14 at 10:37