[Shell command] Write command output to both a file and standard output

Created on November 30, 2026

You can pipe output to tee to display it and save a copy in a file. This example writes Hello World to dummy.txt and prints it.

echo "Hello World" | tee dummy.txt
Hello World

Run cat dummy.txt to see the same line in the file. Use tee -a if you want to append to the file.

Shell command