The tee command can be used to both redirect text to a file and to also display the text in the Terminal. In this example, the text Hello World is both redirected to example.txt and is also displayed in the Terminal.
~]# echo "Hello World" | tee example.txt Hello World
The cat command can be used to ensure that the text Hello World was redirected to example.txt.
~]# cat example.file Hello World
By default, the tee command without any options will overwrite the target file. The -a or --append option can be used to append text to the target file. In this example, the text How are you today is appended to example.txt.
~]# echo "How are you today" | tee -a example.txt How are you today
The cat command can be used to ensure that the text How are you today was appended to example.file.
~]# cat example.txt Hello World How are you today