Skip to content

tee

  • Store and view at same time
# Display and save to a file
echo "Example" | tee "file.txt" # Replaces text (>)
echo "Example" | tee -a "file.txt" # Appends text (>>)

echo "foo" | tee "file1.txt" "file2.txt" # write to multiple files

# Display and save to multiple files
echo "Example" | tee "file1.txt" "file2.txt" "file3.txt"
# privileges to write
sudo echo 1 > "/proc/sys/kernel/sysrq" # won't work! redirect does not have permissions
echo 1 | sudo tee "/proc/sys/kernel/sysrq" # works!