utility

tee

Copy input to stdout and named files. Ordinary tee overwrites named files; -a appends. Use pipefail when all pipeline stages are required. Example writes only an owned synthetic file.

Formal Syntax & Structure

bash syntaxbash
tee [OPTION]... [FILE]...

Return Value

exit status

Copy input to stdout and named files. Ordinary tee overwrites named files; -a appends. Use pipefail when all pipeline stages are required. Example writes only an owned synthetic file.

Working Example

Example Snippetbash
set -o pipefailprintf '%s\n' alpha beta gamma | tee records.txt | wc -lhead -n 1 records.txttail -n 1 records.txt
Bash Reference