tee as pipe inspector

· balazs4's blog


You can use the tee if you want to see what the content of input command but also you would like to pipe it through into another command.

This can be achieved with tee /dev/stderr

tee - read from standard input and write to standard output and files

Since tee writes to the standard output, the following command can reads the content through its standard input, but using tee /dev/stderr in-between, it will also print out everything to standard error which is visible in your terminal.

e.g.:

1printf "%s\n" "foo" "bar" | tee /dev/stderr/ | wc -l
2
3# output
4foo 
5bar
6   2
last updated: