$ tee [option …] [file …]
$ echo xyz | tee /tmp/out.1 /tmp/out.2 xyz $ cat /tmp/out.1 /tmp/out.2 xyz xyz
-a | --append | append to the given FILEs (i. e. do not overwrite) |
-i | --ignore-interrupts | ignore interrupt signals |
-p | diagnose errors writing to non pipes | |
--output-error[=MODE] | set behavior on write error. If --output-error is not specified, tee will exit immediately on error writing to a pipe, and diagnose errors writing to non pipe outputs. | |
--help | ||
--version | output version information and exit |
MODE
determines the behavior with write errors on the output: warn | diagnose errors writing to any output |
warn-nopipe | diagnose errors writing to any output not a pipe |
exit | exit on error writing to any output |
exit-nopipe | exit on error writing to any output not a pipe |
MODE
for the -p
option is warn-nopipe
. tee
can be used in combination with sudo
to create text-files owned by root in a variation of the following pipeline. $ echo 'text text text' | sudo tee /etc/some-config-file
sudo
. 42
. #!/bin/bash >&1 echo "cmd-bad is running" >&2 echo "cmd-bad is failing" exit 42
$PIPESTATUS
is used to query the exit status of the command (rather than tee
's exit status. #!/bin/bash cmd-bad 2>&1 | tee cmd-bad.log echo "\$PIPESTATUS = $PIPESTATUS / \$? = $?"