The tee command

read from standard input and write to standard output and files 6 examples from the lessons of the IVski Linux Playground — try them in the terminal next to them.

Options in the examples

-a, --append
append to the given FILEs, do not overwrite

Examples

command | tee output.txt

Save output to file AND print it

echo '<h1>Hello from my server</h1>' | sudo tee /var/www/html/index.html
echo '<h1>About us</h1>' | sudo tee /var/www/html/about.html
echo secret | sudo tee /var/www/html/secret.html
echo '<h1>Welcome to the shop</h1>' | sudo tee /var/www/shop/index.html
echo '127.0.0.1 shop.local' | sudo tee -a /etc/hosts

Lessons that use tee

Related commands