tee linux shows up when admins need logs on screen and disk — especially with sudo tee for config files. See also tee in shell scripts.
Basic pipe to tee
Split stdout to terminal and file.
bashtee
echo 'deploy ok' | tee /var/log/deploy.log

Append with -a
Do not truncate — use -a for growing logs.
bashappend
date | tee -a /var/log/deploy.log

sudo tee
Redirects do not work with sudo — tee writes the file as root.
bashsudo tee
grep -v '^#' my.conf | sudo tee /etc/app/app.conf > /dev/null

Capture stderr too
Use 2>&1 before the pipe.
bashboth
myscript.sh 2>&1 | tee run.log
tee logging patterns
tee -a for cron outputRelated tutorials
Diagrams are original illustrations by Gnome IT Solutions. Tutorial text © Gnome IT Solutions.