Linux Command Cheat Sheet/Write output to file and stdout

Send output to both a file and the terminal.

Section: Viewing and Text Basics

Write output to file and stdout

bash
bash
make 2>&1 | tee build.log
Explanation

Great for preserving command output while still seeing it live.

Learn the surrounding workflow

Compare similar commands or jump into common fixes when this command is part of a bigger troubleshooting path.

Related commands

Same sheet · prioritizing Viewing and Text Basics
Print file contents
Concatenate and print files to standard output.
OpenIn sheetbashsame section
Page through a file
Open a file in a scrollable pager.
OpenIn sheetbashsame section
Show first lines
Display the first lines of a file.
OpenIn sheetbashsame section
Show last lines
Display the end of a file.
OpenIn sheetbashsame section
Follow a growing file
Stream appended lines as they are written.
OpenIn sheetbashsame section
Count lines words and bytes
Count content in files or streams.
OpenIn sheetbashsame section