tee command
Write output to the screen and to files at the same time.
- Text processing
- Package coreutils
- 2 options · 5 examples
Syntax
tee [options] [file…]Provided by the coreutils package. Run man tee for the full manual.
Common options
| Option | What it does |
|---|---|
-a | Append instead of overwriting |
-i | Ignore interrupt signals |
Examples
Show output and save it
./build.sh | tee build.logAppend to a log
date | tee -a run.logWrite a root-owned file with sudo
echo "vm.swappiness=10" | sudo tee /etc/sysctl.d/99-swap.confAppend to a root-owned file
echo "127.0.0.1 dev.local" | sudo tee -a /etc/hostsSave stdout and stderr
make 2>&1 | tee make.log
No example matches. Check the options table or search the guides.
Tips
sudo echo x > /etc/filefails because the redirect runs as you;| sudo teefixes it.
tee guides
- tee Command in Linux with Examples Linux Commands · Updated Apr 2025
