Text Processing

tee

Read from stdin and write to both stdout and one or more files simultaneously.

Synopsis

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

Examples

Write to screen and file
echo 'log entry' | tee log.txt
Append output to log while displaying
command | tee -a output.log
Capture build output to log and screen
make 2>&1 | tee build.log
Write to root-owned file using sudo
echo 'data' | sudo tee /etc/config

Common options

FlagDescription
-aAppend to files instead of overwriting
-iIgnore interrupt signals

About tee

The `tee` command read from stdin and write to both stdout and one or more files simultaneously. Text processing commands transform, format, and generate text output.

Linux's philosophy of small composable tools shines here — these commands are designed to be piped together to build complex text-processing workflows. They are indispensable for scripting, log analysis, and data transformation tasks.

The command accepts 2 commonly used flags shown above, though the full set of options is available in the man page (`man tee`). The 4 examples on this page cover typical real-world usage patterns that you can copy and adapt for your own workflows.

Related commands

More Text Processing Commands

Other commands in the Text Processing category

Related tools