Linux Command: Tee

“The tee command is normally used to split the output of a program so that it can be both displayed and saved in a file.” wikipedia

tee file.txt

This command create a file.txt and anything you type is : displayed on the screen AND written to the file.

ctrl + z or ctrl + c 

Use this command above to end the session

tee -a file.txt

Same thing as the previous command, except this time it is using the -a (append) flag.

“Note: When tee is used with a pipe, the output of the previous command is written to a temporary file. When that command finishes, tee reads the temporary file, displays the output, and writes it to the file(s) given as command-line argument.” wikipedia

echo "We are YCSoftware" | tee -a file.txt 

The output of the echo command to be written to the file file.txt AND also displayed it on the screen


Let's share thisShare on Facebook
Tweet about this on Twitter
Share on LinkedIn