Linux Text and File Operations Cheat Sheet/Write output to file and stdout

Save command output while still printing it.

Section: Create, touch, truncate

Write output to file and stdout

bash
bash
echo 'hello' | tee hello.txt

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 Create, touch, truncate
Create empty file or update timestamp
Touch a file path.
OpenIn sheetbashsame section
Empty a file without deleting it
Reset file length to zero bytes.
OpenIn sheetbashsame section
Print file content
Output a file to standard output.
Show unified diff
Compare two files in patch-friendly format.
Split file into chunks
Split a large file into 100 MB parts.
Open file with pager
Scroll through a file interactively.