tee

on

The command tee is used to ‘split’ the input (from stdin) to stdout and a file.

Best shown with an example:

ls | grep ' ' | tee -a files_with_spaces.txt | sed 's/ \+/_/g'

this will filter the filenames with spaces, the output will piped to the stdin of tee an will be appended to a file named files_with_spaces.txt (-a means append to file) and the stdout will be piped to a sed command (which replaces the spaces with a underscore).