# Extracting contents of .tgz file

**URL:** <https://discourse.julialang.org/t/extracting-contents-of-tgz-file/75801>\
**Category:** General Usage\
**Tags:** filesystem\
**Created:** [February 4, 2022, 2:45pm UTC](https://discourse.julialang.org/t/extracting-contents-of-tgz-file/75801 "2022-02-04T14:45:29Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Rajesh\_Nakka](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/rajesh_nakka/32/28445_2.png) [@Rajesh\_Nakka](https://discourse.julialang.org/u/Rajesh_Nakka)\
**Post date:** [February 4, 2022, 2:45pm UTC](https://discourse.julialang.org/t/extracting-contents-of-tgz-file/75801/1 "2022-02-04T14:45:29Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![fredrikekre](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/fredrikekre/32/1688_2.png) [@fredrikekre](https://discourse.julialang.org/u/fredrikekre)\
**Post date:** [February 4, 2022, 3:01pm UTC](https://discourse.julialang.org/t/extracting-contents-of-tgz-file/75801/2 "2022-02-04T15:01:13Z")

</div>

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

```julia
using Tar, CodecZlib

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

```
