tee

For filters.

Copy a stream to another command in parallel.

Command Type

built-in

Signature

> tee {flags} (closure)

Flags

  • --stderr, -e: For external commands: copy the standard error stream instead.

Parameters

  • closure: The other command to send the stream to.

Input/output types:

input output
any any

Examples

Save a webpage to a file while also printing it.

> http get http://example.org/ | tee { save example.html }

Save error messages from an external command to a file without redirecting them.

> nu -c 'print -e error; print ok' | tee --stderr { save error.log } | complete

Print numbers and their sum.

> 1..100 | tee { each { print } } | math sum | wrap sum

Do something with a value on another thread, while also passing through the value.

> 10000 | tee { 1..$in | print } | $in * 5
50000

Notes

This is useful for doing something else with a stream while still continuing to use it in your pipeline.

Ported from nushell/nushell.github.io. Copyright (c) 2021 Nushell Project. MIT License.