# Julia shell command tar and pigz pipeline

**URL:** <https://discourse.julialang.org/t/julia-shell-command-tar-and-pigz-pipeline/66175>\
**Category:** New to Julia\
**Tags:** shell\
**Created:** [August 11, 2021, 5:22am UTC](https://discourse.julialang.org/t/julia-shell-command-tar-and-pigz-pipeline/66175 "2021-08-11T05:22:48Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![wuxinyu](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/wuxinyu/32/28059_2.png) [@wuxinyu](https://discourse.julialang.org/u/wuxinyu)\
**Post date:** [August 11, 2021, 5:22am UTC](https://discourse.julialang.org/t/julia-shell-command-tar-and-pigz-pipeline/66175/1 "2021-08-11T05:22:48Z")

</div>

I want to compress a folder in julia:

```bash
tar -cvf - "source" | pigz -k -9 > "source.tar.xz"

```

where `source` is a folder

I tried this in julia:

```julia
run(pipeline(`tar -cvf - "2001_ A Space Odyssey"` , `pigz -k -9 \> "2001_ A Space Odyssey.tar.xz"`))

```

but it didn’t work. I got error below:

```julia
pigz: skipping: > does not exist
pigz: skipping: 2001_ A Space Odyssey.tar.xz does not exist
2001_ A Space Odyssey/
2001_ A Space Odyssey/cover.jpg
ERROR: LoadError: failed process: Process(`pigz -k -9 '>' '2001_ A Space Odyssey.tar.xz'`, ProcessExited(1)) [1]

```

How can I do it in julia?

---

<div class="post-metadata">

**Author:** ![jling](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/jling/32/212909_2.png) [@jling](https://discourse.julialang.org/u/jling)\
**Post date:** [August 11, 2021, 5:42am UTC](https://discourse.julialang.org/t/julia-shell-command-tar-and-pigz-pipeline/66175/2 "2021-08-11T05:42:18Z")

</div>

just like `pipeline` for `|`, you can’t use `>` because that’s also part of the shell and Julia is not sending these through the shell.

One hack you can do is prepend whatever you want to send to shell with `sh -c` and quote the remaining, that way you will be using your actual shell for \>

---

<div class="post-metadata">

**Author:** ![sijo](https://avatars.discourse-cdn.com/v4/letter/s/da6949/32.png) [@sijo](https://discourse.julialang.org/u/sijo)\
**Post date:** [August 11, 2021, 7:34am UTC](https://discourse.julialang.org/t/julia-shell-command-tar-and-pigz-pipeline/66175/3 "2021-08-11T07:34:18Z")

</div>

With `pipeline` the equivalent of `shell_command > destination_file` is to give the destination filename as last argument:

```julia
dir = "2001_ A Space Odyssey"
run(pipeline(`tar -cvf - $dir` , `pigz -k -9`, "$dir.tar.xz"))

```
