tee
for filters
Copy a stream to another command in parallel.
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.