tee
In this page:
tee
tee reads from standard input and writes it both to a file and back out to standard output simultaneously, letting you save output to a log while still seeing it in your terminal. It's often placed in the middle of a pipeline. tee -a appends to the file instead of overwriting it.
Note: Use command | tee log.txt to view output live while also saving it for later.
Example: tee
#!/bin/bash
echo "Important message" | tee log.txt
echo "--- contents of log.txt ---"
cat log.txt
Login to try C/C++/Java/PHP code in the editor
🔒
Chapter Quiz — Complete all 14 topics to unlock
0/14 topics done
Complete these topics first: