|| visible in terminal || visible in file || existing Syntax || StdOut | StdErr || StdOut | StdErr || file ==========++==========+==========++==========+==========++=========== > || no | yes || yes | no || overwrite >> || no | yes || yes | no || append |||||||| 2> || yes | no || no | yes || overwrite 2>> || yes | no || no | yes || append |||||||| &> || no | no || yes | yes || overwrite &>> || no | no || yes | yes || append |||||||| | tee || yes | yes || yes | no || overwrite | tee -a || yes | yes || yes | no || append |||||||| n.e. (*) || yes | yes || no | yes || overwrite n.e. (*) || yes | yes || no | yes || append |||||||| |& tee || yes | yes || yes | yes || overwrite |& tee -a || yes | yes || yes | yes || append
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16
tee
Read from standard inputandwriteto standard output andfiles (or commands). More information: https://www.gnu.org/software/coreutils/tee.
- Copy standard inputto each file, and also to standard output: echo"example" | tee path/to/file
- Append to the given files, do not overwrite: echo"example" | tee -a path/to/file
- Print standard inputto the terminal, and also pipe it into another program for further processing: echo"example" | tee /dev/tty | xargs printf"[%s]"
- Create a directory called "example", count the number of characters in "example"andwrite"example"to the terminal: echo"example" | tee >(xargs mkdir) >(wc -c)