tee Table of Contents tee tee reference $ echo 'foo' | tee foo.txt foo $ cat foo.txt foo $ cat foo.txt foo $ echo 'bar' | tee -a foo.txt # append bar $ cat foo.txt foo bar # Redirecting stdout is not affected by 'sudo' $ echo 'foo' >> file zsh: permission denied: file # 'tee' can be used to work around this $ echo "foo" | sudo tee -a file https://shapeshed.com/unix-tee/