<mohammadrony>

tee

Commands

Save text to new file

tee file.txt << eof
hello!
eof

Append new text

tee -a file.txt << eof
hello world!!
eof

Watch command output and save in file

while true; do date; sleep 1; done |& tee -a file.txt
watch '(date; sleep 1) | tee -a file.txt'

Related question