# How to capture run/pipeline output

**URL:** https://discourse.julialang.org/t/how-to-capture-run-pipeline-output/16155
**Category:** New to Julia
**Created:** [October 11, 2018, 6:31am UTC](https://discourse.julialang.org/t/how-to-capture-run-pipeline-output/16155 "2018-10-11T06:31:16Z")
**Posts on this page:** 4
**Page:** 1

<div class="post-metadata">

### Author: ![tk3369](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/tk3369/32/2824_2.png) [@tk3369](https://discourse.julialang.org/u/tk3369)
#### Post date: [October 11, 2018, 6:31am UTC](https://discourse.julialang.org/t/how-to-capture-run-pipeline-output/16155/1 "2018-10-11T06:31:16Z")

</div>

As an example, the following code has `1 1 4` printed in the console. How do I capture that into a string variable?

```julia
run(pipeline(`echo 123`, `wc`))

```

---

<div class="post-metadata">

### Author: ![kdyrhage](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/kdyrhage/32/2326_2.png) [@kdyrhage](https://discourse.julialang.org/u/kdyrhage)
#### Post date: [October 11, 2018, 7:09am UTC](https://discourse.julialang.org/t/how-to-capture-run-pipeline-output/16155/2 "2018-10-11T07:09:32Z")

</div>

```julia
s = readlines(pipeline(`echo 123`, `wc`))

```

or

```julia
s = readstring(pipeline(`echo 123`, `wc`))

```

---

<div class="post-metadata">

### Author: ![kdyrhage](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/kdyrhage/32/2326_2.png) [@kdyrhage](https://discourse.julialang.org/u/kdyrhage)
#### Post date: [October 11, 2018, 7:27am UTC](https://discourse.julialang.org/t/how-to-capture-run-pipeline-output/16155/3 "2018-10-11T07:27:55Z")

</div>

There’s yet another solution in [the docs](https://docs.julialang.org/en/v1/manual/running-external-programs/#Running-External-Programs-1):

```julia
read(pipeline(`echo 123`, `wc`), String)

```

This is equivalent to the `readstring` example.

---

<div class="post-metadata">

### Author: ![Liso](https://avatars.discourse-cdn.com/v4/letter/l/898d66/32.png) [@Liso](https://discourse.julialang.org/u/Liso)
#### Post date: [October 11, 2018, 10:57am UTC](https://discourse.julialang.org/t/how-to-capture-run-pipeline-output/16155/4 "2018-10-11T10:57:57Z")

</div>

Cool! 🙂

And you could read lines asynchronously too! 😱

````julia
julia> import Dates
julia> r = eachline(```
       julia -e """
          for i in 1:3 
            sleep(1)
            println('*') 
          end"""
       ```);
julia> for i in r 
         println("$i $(Dates.now(Dates.UTC))")
       end;
       
* 2018-10-11T10:43:28.4
* 2018-10-11T10:43:29.402
* 2018-10-11T10:43:30.404

````
