Эхо с командой TEE
echo 'foo' | tee foo.txt
foo
cat foo.txt
foo
Tiago F2
echo 'foo' | tee foo.txt
foo
cat foo.txt
foo
# append
cat foo.txt
foo
echo 'bar' | tee -a foo.txt
bar
cat foo.txt
foo
bar