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:

inputoutput
anyany

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

Notes

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