Skip to main content

Command referencetee

tee command (Linux / bash / sh / zsh)

Linuxbashshzshtextbeginner

What it does

Copy standard input to standard output and one or more files. When people search for the tee command linux output file, they usually want tee's everyday flags, safe examples, and how it differs from related tools. Below you'll find syntax, options, and copyable examples for Bash/sh/zsh.

Copy standard input to standard output and one or more files.

Syntax

tee [OPTION]... [FILE]...

Common options

Flag / optionMeaning
-aAppend rather than overwrite.
-iIgnore interrupt signals.
-pDiagnose errors writing to pipes.
--output-error=MODEControl write-error handling.

Practical examples

Save and display

make | tee build.log

Shows build output while recording it.

Append log

echo 'deployed' | tee -a deploy.log

Adds a line and echoes it.

Write privileged file

echo 'value=1' | sudo tee /etc/app.conf >/dev/null

Lets tee perform the elevated write.

Common mistakes

  • Forgetting that tee overwrites files unless `-a` is used.
  • Using `sudo echo ... > file`; redirection is not elevated.

FAQ

What does tee do in Linux?

Copy standard input to standard output and one or more files.

How do I use tee from the terminal?

Start with `tee [OPTION]... [FILE]...`, then choose only the options needed for the task.

What is a practical tee example?

Try `make | tee build.log` — Shows build output while recording it.

Can I use tee in a shell script?

Yes. tee works in Bash, sh, and Zsh, but scripts should handle quoting, errors, and command output explicitly.

Browse the full Linux and Windows command reference to search more bash, CMD, PowerShell, Conda, and GitHub CLI commands.