Extracting contents of .tgz file

I am trying to extract contents of a file with tgz extension. I have tried Tar.jl, CodecZlib.jl, Tariterators.jl …etc. without success.

I think they have the necessary capabilities but I am not sure how to get it. Could you please share a sample snippet for extracting the contents of sample.tgz

PS1: I am able to do similar task on zip files using ZipFile.jl. I am looking for the ones with .tgz extension.

PS2: the tgz file, I am working with has large number of files but I need only three of them. It would be great, if I can write only those three files without writing redundant files. I am able to achieve this with ZipFile.jl

Thanks in advance.

Here is how you can extract a file test.tar.gz to a directory output:

using Tar, CodecZlib

open(GzipDecompressorStream, "test.tar.gz") do io
    Tar.extract(io, "output")
end
3 Likes