Skip to content

tee command

Write output to the screen and to files at the same time.

On this page

Syntax

tee [options] [file…]

Provided by the coreutils package. Run man tee for the full manual.

Common options

OptionWhat it does
-aAppend instead of overwriting
-iIgnore interrupt signals

Examples

  1. Show output and save it

    ./build.sh | tee build.log
  2. Append to a log

    date | tee -a run.log
  3. Write a root-owned file with sudo

    echo "vm.swappiness=10" | sudo tee /etc/sysctl.d/99-swap.conf
  4. Append to a root-owned file

    echo "127.0.0.1 dev.local" | sudo tee -a /etc/hosts
  5. Save stdout and stderr

    make 2>&1 | tee make.log

Tips

  • sudo echo x > /etc/file fails because the redirect runs as you; | sudo tee fixes it.

tee guides

← All Linux commands · Suggest a fix

Back to top