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

Sim­ply pipe the out­put of your com­mand to the tee com­mand. See exam­ples below.

ls | tee filename

The tee com­mand over­writes the out­put file. To append, use

$ ls | tee –a file

To send your out­put to mul­ti­ple files, sim­ply spec­ify files one after the other

$ ls | tee –a file1 file2

Ryan Sukale

Ryan is a UX engineer living in San Francisco, California.

You may also like...