• 0

Redirect linux command output to a file as well as to the terminal

Simply pipe the output of your command to the tee command. See examples below.

ls | tee filename

The tee command overwrites the output file. To append, use

$ ls | tee –a file

To send your output to multiple files, simply specify files one after the other

$ ls | tee –a file1 file2